【发布时间】:2015-04-14 17:17:05
【问题描述】:
我正在尝试在 url 中添加一个斜杠。它几乎可以工作,但有一个我不明白的小问题。
当我调用该站点http://domain.com/test > 重写到 www.domain.com > 添加尾部斜杠。
当我直接调用该站点http://www.domain.com/test > 没有添加任何内容。 对我来说重要的是 https:// 必须重定向到 https:// 而不是 http://
这是我的配置:
############################################
启用重写
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !.html
RewriteCond %{REQUEST_URI} !.php
RewriteCond %{QUERY_STRING} !price
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1/ [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1/ [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php [L]
【问题讨论】:
标签: .htaccess mod-rewrite