.htaccess htaccess重定向无法正常工作
我的网页URL应以开头。我的一些重定向无法正常工作。我要举的例子是:.htaccess htaccess重定向无法正常工作,.htaccess,redirect,.htaccess,Redirect,我的网页URL应以开头。我的一些重定向无法正常工作。我要举的例子是: romancestuck.com/aboutus/amycunningham.htm 应重定向到: https://www.romancestuck.com/aboutus.htm 但它却陷入了重定向循环 my.htaccess文件中的代码是: RewriteEngine On RewriteBase / ### REDIRECT NON-WWW TO WWW - START ### RewriteCond %{HT
romancestuck.com/aboutus/amycunningham.htm
应重定向到:
https://www.romancestuck.com/aboutus.htm
但它却陷入了重定向循环
my.htaccess文件中的代码是:
RewriteEngine On
RewriteBase /
### REDIRECT NON-WWW TO WWW - START ###
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301]
### REDIRECT NON-WWW TO WWW - END ###
### REDIRECT NON-HTTPS TO HTTPS - START ###
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
### REDIRECT NON-HTTPS TO HTTPS - END ###
redirect 301 /aboutus/amycunningham.htm https://www.romancestuck.com/aboutus.htm
任何帮助都将不胜感激 像这样重构规则:
RewriteEngine On
RewriteRule ^aboutus/amycunningham\.htm$ https://www.romancestuck.com/aboutus.htm [L,NC,R=302]
### REDIRECT NON-WWW TO WWW & REDIRECT NON-HTTPS TO HTTPS ###
RewriteCond %{HTTP_HOST} !^www\. [OR]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.romancestuck.com%{REQUEST_URI} [R=302,L,NE]
请记住在新浏览器中进行测试,或者在测试之前清除浏览器缓存
确认其工作正常后,将R=302更换为R=301。在测试mod_重写规则时,避免使用R=301永久重定向