.htaccess没有将网站重定向到https:// www

时间:2017-06-28 23:38:42

标签: .htaccess redirect mod-rewrite

我正在为我的网站编写我的重定向,但我无法让它工作,我已将其拆分,因此它会自动重定向到https://www.whereshouldieat.ie,但是因为为此添加了重写index.php网站的重定向不起作用,甚至在删除index.php的重写时,它也不会重定向到我设置的内容。请参阅下面的内容。

#rewrite domain name
RewriteEngine On
   RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.whereshouldieat.ie/$1 [R,L]

#rewrite index.php        
  RewriteEngine On
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

    ## Leverage browser caching at HostPapa ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## End leverage browser caching ##

有人可以提供建议吗?我不确定我做错了什么。

1 个答案:

答案 0 :(得分:0)

尝试这样做,(未经过测试!)

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

希望这会有所帮助。