Forum Moderators: phranque
RewriteEngine On
RewriteRule ^book/([^/\.]+)/?$ book.php?redirectNAME=$1 [L]
to have
www.XXX.com/book.php?redirectNAME=BookName
become
www.XXX.com/book/BookName/
please help I'm totally confused why this doesn't work.
Do you have access to your server error log file? A common problem is that mod_rewrite requires FollowSymLinks or SymLinksIfOwnerMatch to be enabled before mod_rewrite will function. If you do not have this setting, your code will have no effect, but your server error log will tell you of this exact problem.
Try an even simpler rewrite:
RewriteEngine On
RewriteRule ^test\.html$ /book.php?redirectNAME=Bookname [L]
Next, Flush your browser cache.
Now type http://www.yourdomain.com/test.html into your browser and click "go".
You should see the output of the page http://www.yourdomain.com/book.php?redirectNAME=Bookname, but the browser address bar should remain unchanged and still show http://www.yourdomain.com/test.html
Jim
SO it seems to work. But I'm still not able to have the redirect work for the /book/BookName/ idea. AM I missing something? I have a blog that uses redirects on the same server just fine as well. Is my htaccess code wrong? I'm totally lost here.
RewriteEngine On
RewriteRule ^book/([^/.]+)/?$ /book.php?redirectNAME=$1 [L]
Jim
Some good advice there about doing the test thing. I was having trouble with converting a dynamic site to use mod_rewrite to make "real" URLs. I set up a test html page with all of the possible url combinations of rewrite that I would need and then clicked the links - on at a time - making sure the mod_rewrite code handled that specific situation. After two days of coding I have a fully mod_rewrite enaabled version of the site.
To quote the apache docs - mod_rewrite is voodoo!
Using a series of simple tests makes life a lot easier.