我有.htaccess文件,但它没有按预期工作。
Redirect /some/dir http://www.example.com/someother/dir/29
<IfModule mod_rewrite.c>
RewriteEngine on
# HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !=/buy/confirm
RewriteCond %{REQUEST_URI} !=/index.php
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !=/some/dir
RewriteRule ^(.*)$ index.php?issue=$1 [L,QSA]
</IfModule>
我一直在用http://www.example.com/buy/confirm查看此内容,当我输入“https://twitter.com/laravellog/status/857629925834203136?lang=en”时我不明白一行:
RewriteCond %{REQUEST_URI} !=/buy/confirm This condition was met.
确切包含%{REQUEST_URI}以满足条件!= /购买/确认?我已经尝试了/买/确认和购买/确认,没有。
如果网址为buy / confirm,我不想重定向到HTTPS。
谢谢!
答案 0 :(得分:0)
试试这个:
RewriteEngine On
#redirect everything except /buy/confirm to https
RewriteCond %{HTTPS} =off
RewriteCond %{REQUEST_URI} !^\/buy\/confirm\/
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]
#redirect /buy/confirm to http if it is accesed by https
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} \/buy\/confirm\/
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]
答案 1 :(得分:0)
您可以使用:
Redirect /some/dir http://www.example.com/someother/dir/29
<IfModule mod_rewrite.c>
RewriteEngine on
# HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/buy/confirm
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/favicon.ico
RewriteCond %{REQUEST_URI} !^/some/dir
RewriteRule ^(.*)$ index.php?issue=$1 [L,QSA]
</IfModule>