0

Im new to this I want to write .htaccess file for my project.I wrote this code as im running on my localhost :-

RewriteEngine on
RewriteRule ^http://192.168.1.185/location/new/project/rss\.php$   http://192.168.1.185/location/new/project/folder/rss.php

I want to redirect http://192.168.1.185/location/new/project/rss.php to http://192.168.1.185/location/new/project/folder/rss.php

This not working.Is im doing anything wrong? please help me on this thanks in advance

3 Answers 3

1

Rewrite rules only take the path part of the URL (URI) into consideration (an excellent article on mod_rewrite). The rest is ignored.

However, if your redirection needs to be permanent its much better to avoid mod_rewrite and simply use Redirect.

Redirect /vroomrelocation/new/vroomvroom/rss.php /vroomrelocation/new/vroomvroom/yash/rss.php
Sign up to request clarification or add additional context in comments.

4 Comments

Yes. You could also specify what response code will be sent to the requester (301, 302, etc.) which is explained on the link I provided (the one regarding Redirect).
For the URLs you specified in your comment it would be enough to simply use Redirect /yash/rss.php /rss.php however do take note that this is the opposite situation from the one you specified in the question. I mean here is /yash/rss.php redirected to rss.php but in your question you asked how to redirect /rss.php to /yash/rss.php. Whatever redirection you want the URL on the left in the Redirect directive is the URL you want to redirect and the one on the right is the URL to which you want to redirect the first URL.
i want to redirect to rss.php from /yash/rss.php. can i use http:// in front of them ?
No you can't because the first URL needs to be a path (begins with /) since its always considered to be part of the site itself. The second URL can contain http:// but there is no need to here because its also on the same web site (domain). You would only need to use it if you were to use external redirection.
1

I'm no expert in htaccess myself, but this should work:

# Redirect old file path to new file path
Redirect rss.php http://192.168.1.185/vroomrelocation/new/vroomvroom/yash/rss.php

And put it in the rss.php directory, not the base directory.

Comments

0

If you want to put the .htaccess file inside the root of your website, you should write:

Redirect /vroomrelocation/new/vroomvroom/rss.php /vroomrelocation/new/vroomvroom/yash/rss.php

I recommend to put the file inside /vroomrelocation/new/vroomvroom/ and write:

Redirect rss.php yash/rss.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.