2013-02-05 50 views
1

我创建了一个.htaccess文件,它执行两件事:将http重定向到https和www。非www。下面是代码:在Firefox中的Mod重写问题

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

RewriteBase/
RewriteCond %{HTTP_HOST} ^www.profstream.com [NC] 
RewriteRule ^(.*)$ https://profstream.com/$1 [L,R=301] 

这正常在Chrome,Safari和Opera,但是,当我例如在Firefox中键入profstream.com/sandbox/login.php它重定向到https://profstream.com/https://www.profstream.com/sandbox/login.php某种原因。我在这里做错了什么?

回答

1

我认为你缺少[L],也[QSA],试试这个:

RewriteCond %{HTTPS} off 
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L] 

L是离开,否则就会在此之后使用的规则。
QSA是添加URL的查询字符串。

第二部分应该是这样的,我认为:

不知道有关RewriteBase /是,需要

RewriteCond %{HTTP_HOST} ^www.profstream.com [NC] 
    RewriteRule (.*) https://profstream.com%{REQUEST_URI} [QSA,L] 
,?

如果你想既要发生的,也许你应该颠倒顺序

RewriteCond %{HTTP_HOST} ^www.profstream.com [NC] 
    RewriteRule (.*) https://profstream.com%{REQUEST_URI} [QSA,L] 

    RewriteCond %{HTTPS} off 
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L] 
+0

嗯......仍然在Firefox同样的事情......就像我说的,它的怪异,它的一切工作正常其他浏览器减去Firefox。不过谢谢你的详细回答,我真的很感激。 – Arun

+0

你真的确定你正在使用我写的建议吗?当您在问题中使用规则时,合理的做法是使用“组合”URL获得结果。 **不要**使用'RewriteBase'。你尝试了两个建议? (以相反的顺序使用规则)。 – 244an

+0

谢谢!原来你的代码工作得很好。只需要清除历史记录。 – Arun