Apache Rewrite or Redirect?
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]
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]