View Full Version : htaccess rewrite url

06-27-2011, 05: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?

www.domain.com/subfolder/file.php?a=1&b=2 [L]
to www.domain.com/foo/bar

06-27-2011, 09:54 AM
RewriteRule ^foo/bar$ /subfolder/file.php?a=1&b=2 [L] ?

06-28-2011, 12: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.

07-08-2011, 10:40 PM
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, 03:47 PM
Thanks, I was looking for the same thing

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum