忽略.htaccess中的apache重定向
问题描述:
我有这个简短的.htacccess文件。忽略.htaccess中的apache重定向
Redirect permanent /home http://www.example.com/
RewriteEngine On
RewriteRule ^(home|about|gallery|video|crafts|contact|press)$ /$1.html [L]
DirectoryIndex home.html
所有的它工作在我的本地MAMP安装。
的第一行不我的实际Apache服务器上工作(URL传递不变)(Debian的。)
我试着重定向上方和下方的重写规则,并与有和没有第一URL前面的斜线(/ home和home)。
我在/ etc/apache2/sites-available的conf文件中有一个'AllowOverride All',正如我所说的那样,该文件的其余部分正在兑现。
mod_alias中安装(在/ etc启用MODS-/ Apache2的/ /)
我没有看到在错误日志什么。
有什么想法?
答
试试这个代码在你.htacces文件:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase/
RewriteRule ^home/?$ http://www.example.com/ [L,NC,R=301]
RewriteRule ^(about|gallery|video|crafts|contact|press)/?$ $1.html [L,NC]
我敢肯定,这将工作,但你有任何的理论,为什么简单的“重定向”指令,是不是? – 2012-01-04 10:05:54
我不确定为什么'重定向永久/主页http:// www.example.com /'不适用于您的设置。我也尝试过,并且对我有用。 – anubhava 2012-01-04 12:13:25