Apache .htaccess Redirect and RedirectPermanent directives do nothing

Apache .htaccess Redirect and RedirectPermanent directives do nothing - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, apache, 301-redirect, .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


I am trying to do a very simple redirect for an entire web site using instructions from sites like this and this, and several others that say the same thing. I am using Apache. My .htaccess file contains this:



Redirect 301 / http://www.example.com/


It does not have any effect at all. I've also tried using RedirectPermanent, with the same result. Is there another setting somewhere else that affects this?


Solution :

There is indeed another setting that controls redirects. To make Apache look at .htaccess, it is necessary to change the AllowOverrides line in the apache .conf file for the site:



<Directory /var/www/oldsite/>
Options FollowSymLinks
AllowOverride **None**
Require all granted
</Directory>


You can replace None by All to enable all directives, or by Fileinfo if you simply want to enable the group of directives that include Redirect. You can read more about the AllowOverride control in the Apache core guide.


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect