0
嗨有點卡住我的.htaccess文件規則。非www到www,尾部斜槓,非https到https和友好的URL
我已經設置了非HTTPS重定向到HTTPS(這個工程):
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
我已經設置了非萬維網到www(這個工程):
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
我已經建立了這樣它總是添加尾隨斜線的網址(這增加了尾部斜槓感謝you.php):
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !/$
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L]
重定向(不工作):
RewriteRule ^thank-you/?$ thank-you.php [L]
RewriteRule ^thank-you.php$ http://%{HTTP_HOST}/thank-you/ [L]
應該發生的是,如果有人去,不是WWW或不是http他們將被重定向到https和www任何地址。
磨感謝you.php訪問它應該重定向到文件/感謝信/
如果有人訪問/感謝你應該重定向到/感謝信/
開始有點由於網址重新寫入無法正常工作,但看起來應該如此。
在此先感謝
全碼:
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !/$
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L]
RewriteRule ^thank-you/?$ thank-you.php [L]
RewriteRule ^thank-you.php$ http://%{HTTP_HOST}/thank-you/ [L]
現在什麼奇怪的是,這段代碼重定向到/thank-you.php /感謝信/但不重定向/感謝你/謝謝,你/我覺得有什麼衝突:
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !/$
RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI}/ [R=301,L]
RewriteRule ^thank-you/?$ thank-you.php [L]
RewriteRule ^thank-you.php$ http://%{HTTP_HOST}/thank-you/ [L]