View Full Version : htaccess rewrite url
06-27-2011, 06:00 AM
I am using this code to rewrite the url if the file is in the main directory.
www.domain.com/file.php?a=1&b=2 [L]to www.domain.com/bar using
RewriteRule ^bar$ /file.php?a=1&b=2 [L].
How can I insert a subfolder?
06-27-2011, 10:54 AM
RewriteRule ^foo/bar$ /subfolder/file.php?a=1&b=2 [L] ?
06-28-2011, 01:31 AM
Ok, i finally got it to work by using this code
RewriteRule ^bar$ /foo/bar.php?a=1&b=1 [L]
The key is to put this code in the foo folders .htaccess file.
I thought that was the case but when I tested it, i must have missed a slash or something.
If you wish to keep all your rules together, you should only have to append the subfolders name to the match.
RewriteRule ^foo/bar$ /foo/bar.php?a=1&b=1 [L]
... or even ...
RewriteRule ^(foo/bar)$ /$1.php?a=1&b=1 [L]
07-12-2011, 04:47 PM
Thanks, I was looking for the same thing
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.