...

View Full Version : Rewrite Help



tomharto
01-18-2011, 05:48 AM
A while ago i was kinda getting there with Rewrite, but i've not done it in a while and totally lost it. Basically what im trying to do is if someone types "www.example.co.uk/sub/brochure", it to redirect to "www.example.co.uk/sub/index.php?page=brochure". Im not sure if thats possible or if it would have to be like ".co.uk/sub/page/brochure", but either way i cant get it working. Because the .htaccess is stored in the same folder as the "sub" folder, i tried "RewriteRule ^sub/([a-z]+)$ /sub/index.php?page=$1/ [R]" but that didnt work, and i tried messing about a few other ways but with no look, if anyone can gimmie a hand getting this basic one started im sure i can pick the rest up again.

Thanks

poyzn
01-18-2011, 08:46 AM
try this code


RewriteEngine On
RewriteCond %{REQUEST_URI} ^\/sub\/
RewriteRule ^sub/([a-z]+)\/?$ /sub/index.php?page=$1 [L]

tomharto
01-18-2011, 09:08 AM
Thanks, ill give that a try later on when i get access to a ftp, what does the REQUEST URI line do?

poyzn
01-18-2011, 10:17 AM
Thanks, ill give that a try later on when i get access to a ftp, what does the REQUEST URI line do?

it reads requested uri and apply next rewrite rule only for the matching

tomharto
01-18-2011, 10:38 AM
Oh, ok thanks. Im still VERY new to all of this so i have a lot to learn :P



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum