I want to redirect a http://site.com/ to http://site.com/url What is the simplest way to do this? I tried editing httpd.conf and to the redirect command. It didn't worked Also I tried creating a file on sites-enabled with rewrite commands. also didn't worked out. sample config on sites-enabled: RewriteEngine On RewriteRule /.* http://site.com/url [R]

link|improve this question

22% accept rate
Do you want an internal redirect (browser URL remains /) or do you want a browser redirect (browser URL becomes /url) ? – Rob Olmos Dec 2 '10 at 5:36
I am not familiar with the terms but I think I want a browser redirect. So for example, whenever a user access serverfault.com, it will be redirected to serverfault.com/questions – Jonar Dec 2 '10 at 11:49
feedback

1 Answer

This is bad practice, and search engines like Google will give you a lower score for not serving content on the base url if its linked to, however...

Your redirects are recursive in both situations, you need to make it so that it wont redirect once its at the correct url, e.g.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/url
RewriteRule ^.* /url [L,R]

I think in the case of your redirect, you shouldn't need to redirect everything to that url, just the root url.

RewriteEngine On
RewriteRule ^/$ /url [L,R]
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.