...

please help in htaccess redirect

crazy.works
02-25-2009, 08:24 PM
hello,
i wanna redirect php file called file.php to path called /web/ in the same directory .

so i was trying like that

RewriteEngine on
Options +FollowSymlinks
RewriteRule ^file\.php$ /web/ [R=301,L]


but it redirected me to my main site url web/ with ignoring the file.php directory and the its path too, i mean the file.php in url www.mysite.com/path1/path2/file.php , i uploaded the htaccess file in path2 folder

but my rule redirected me to www.mysite.com/web/ not www.mysite.com/path1/path2/web/ !!!!!!


so please for some reason i cant write the path in the rule, i mean i cant write like that
RewriteRule ^file\.php$ path1/path2/web/ [R=301,L]

it gonna works but i have reason that makes me not able to do it and i have to got direct rule without write path in the htacces file

so please help me in that

thanks

tomws
02-25-2009, 09:31 PM
If you just want to redirect, you don't need a rewrite rule. You just need a redirect. And if it really is a php file, you don't even need to go into htaccess, you can just have php send a header(Location:balhblahblah) and redirect that way. Much simpler.

If you don't like that method, Redirect and Alias (http://httpd.apache.org/docs/2.2/mod/mod_alias.html) would be easier than url rewriting.

crazy.works
02-26-2009, 08:22 AM
well , thanks for the reply .

about the php header , i know about it sure .
but this htaccess will use in more than one host so , i have to set it , not in php

so about the link that u just sent , iam thankful for it , but it doesnt work as i want

i inserted that code in the htaccess file
RedirectMatch (.*)file\.php$ /web/

it redirected me to www.mysite.com/web/ with ignoring the path that the htaccess uploaded into

so how can i make it redirect to /web/ in the same path that i uploaded the htaccess into, is there path query for the htaccess like [PHP_SELF] in the php ??? or what i have to do please

thanks

abduraooft
02-26-2009, 08:29 AM
is there path query for the htaccess like [PHP_SELF] in the php ???
There are many things like REQUEST_URI and HTTP_HOST to fine tune your redirect rules.

crazy.works
02-26-2009, 08:47 AM
thanks i got it done with adding variable for the path
RedirectMatch (.*)file\.php$ $1web/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum