Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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, it didn't work out.

Sample config on sites-enabled:

RewriteEngine On
RewriteRule /.* http://site.com/url [R]
share|improve this question
    
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
1  
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

1 Answer 1

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]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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