Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-25-2009, 08:24 PM   PM User | #1
crazy.works
Regular Coder

 
Join Date: Jul 2008
Posts: 150
Thanks: 24
Thanked 0 Times in 0 Posts
crazy.works is an unknown quantity at this point
please help in htaccess redirect

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
crazy.works is offline   Reply With Quote
Old 02-25-2009, 09:31 PM   PM User | #2
tomws
Senior Coder

 
tomws's Avatar
 
Join Date: Nov 2007
Location: Arkansas
Posts: 2,644
Thanks: 29
Thanked 330 Times in 326 Posts
tomws will become famous soon enoughtomws will become famous soon enough
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 would be easier than url rewriting.
__________________
Are you a Help Vampire?
tomws is offline   Reply With Quote
Users who have thanked tomws for this post:
crazy.works (02-26-2009)
Old 02-26-2009, 08:22 AM   PM User | #3
crazy.works
Regular Coder

 
Join Date: Jul 2008
Posts: 150
Thanks: 24
Thanked 0 Times in 0 Posts
crazy.works is an unknown quantity at this point
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
crazy.works is offline   Reply With Quote
Old 02-26-2009, 08:29 AM   PM User | #4
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
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.
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 02-26-2009, 08:47 AM   PM User | #5
crazy.works
Regular Coder

 
Join Date: Jul 2008
Posts: 150
Thanks: 24
Thanked 0 Times in 0 Posts
crazy.works is an unknown quantity at this point
thanks i got it done with adding variable for the path
RedirectMatch (.*)file\.php$ $1web/
crazy.works is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:12 PM.


Advertisement
Log in to turn off these ads.