Forum Moderators: phranque
I'm trying to set up search engine friendly urls for my dynamic sites that run on php. So far I have tried something really simple by changing one file to another using rewrite. I then tried to rewrite a url that looked something like this
www.mydomain.com/testfolder/test/1
to become
www.mydomain.com/testfolder/test.php?f=1
I used a .htaccess file which is in the testfolder. Here is the code i have tried to use but it doesn't work.
RewriteEngine On
RewriteRule ^test/([0-9]*)$ /testfolder/test.php?f=$1 [L]
I have nothing else in the .htaccess file.
Any help would be appreciated! :-)
RewriteLog file-path
RewriteLogLevel Level
Depending on the LogLevel, you'll see which conditions have matched, and how urls are transformed.
The ^ caret at the beginning of the left expression signifies "start of string", but your full url doesn't start with test....
You might want to try:
RewriteRule ^testfolder/test/([0-9]*)$ /testfolder/test.php?f=$1 [L]
You might also want to browse the online docs:
httpd.apache.org/docs-2.0/mod/mod_rewrite.html#rewriterule
RewriteEngine On
RewriteBase /testfolder
RewriteRule ^/news$ /news.php [L]
I'm using shared hosting so I think I need to use the RewriteBase, is this right? I have tried this code but still getting 404s.
Any help again would be appreciated. Thanks
RewriteEngine On
RewriteRule ^news/?$ /news.php [L]
Options +FollowSymLinks
Jim