将网址重写为https:// www

时间:2017-07-23 06:35:46

标签: .htaccess

我已经看到了有关将所有网址重写为https://www的几个主题 但我无法最终设置htaccess工作, 我刚才的htaccess代码如下:

RewriteEngine On  
RewriteRule    ^([a-zA-Z]+)/rss\.xml/?$    rss.php/$1    [NC,L]
RewriteRule    ^fa/post/([0-9]+)/([^/]*)/?$    /post.php/$1     [NC,L]
RewriteRule    ^fa/product/([0-9]+)/([^/]*)/?$    /product.php/$1     [NC,L]
RewriteRule    ^fa/subject/([0-9]+)/([^/]*)/?$    /subject.php/$1      [NC,L]
RewriteRule    ^fa/gallery/([0-9]+)/([^/]*)/?$    /gallery.php/$1      [NC,L]
RewriteRule    ^fa/poll/([0-9]+)/([^/]*)/?$    /poll.php/$1      [NC,L]
RewriteRule    ^fa/([^/]*)$    index.php/$1   [NC,L]
RewriteRule    ^sitemap\.xml$    sitemap.php   [NC,L]
RewriteRule    ^posts(/?)$    posts.php   [NC,L]
RewriteRule    ^tag/([^/]*)/?$    /tag.php?value=$1     [NC,L]
RewriteRule    ^cat/([0-9]+)/([^/]*)/?$    /tag.php?value=$2     [NC,L]


RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off 
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://www.zanjan.org%{REQUEST_URI} [R=301,L,NE] 

除了这两个外,所有网址似乎都运行良好:

zanjan.org/cat/SomeNumberHere/SomeWordHere
zanjan.org/tag/SomeWordHere

示例1:http://zanjan.org/cat/2/usa

示例2:http://zanjan.org/tag/usa

以上页面没有转到https://www,而代理商甚至会向我显示以下错误(chrome):

zanjan.org unexpectedly closed the connection.
ERR_CONTENT_LENGTH_MISMATCH

和FireFox中的空白页面。

如何让它们起作用?

1 个答案:

答案 0 :(得分:1)

将您的 Error:(119, 37) error: incompatible types: <anonymous android.support.v7.internal.widget.AdapterViewCompat.OnItemClickListener> cannot be converted to android.widget.AdapterView.OnItemClickListener 重定向规则移至RewriteEngine下方,并在其他浏览器中进行测试。通常,重定向规则应放在所有内部重写规则之上:

https

此外,我已将您的5个类似的重写规则合并为一个规则。

相关问题