[UPHPU] Rewriting Apache URLs
Wade Preston Shearer
lists at wadeshearer.com
Mon Aug 7 08:51:19 MDT 2006
> I have noticed on a couple of sites the URL is something like
> http://www.somesite.com/index.php/2006/08/07/articleName . I know
> this
> help with SEO, it also makes for a more meaningful URL compared to my
> current method of index.php?articleID=143. I know this isn't strictly
> PHP related but if anyone will know you guys will. How can I get
> apache
> to accept this as a URL and PHP to properly interpret it?
A, make sure that mod_rewrite is enabled.
B, add this to you .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
C, put some logic in "index.php" that interprets the URL. The syntax
for this would depend on what you want to match it up to. Basically,
all you do is grab the URL (inside of the _SERVER array), explode it,
and then use the variables piece together what you need.
Note, I would recommend leaving the filename out of URL, like this:
http://www.somesite.com/2006/08/07/articleName
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2425 bytes
Desc: not available
Url : http://uphpu.org/pipermail/uphpu/attachments/20060807/5298699a/smime.bin
More information about the UPHPU
mailing list