这两个.htaccess片段的行为是否相同,或者对于某些用例而言是否有益?.htaccess永久重定向比较
目标是将网站的域名从www.oldexample.com
更改为www.newexample.com
。它应该解释来自www.oldexample.com的子目录和页面,这些子目录和页面将继续存在于www.newexample.com下相同的路径中。
片段1
RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldexample.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldexample.com [NC]
RewriteRule ^(.*)$ https://www.newexample.com/$1 [L,R=301,NC]
片段2
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*) https://www.newexample.com%{REQUEST_URI} [L,R=301,NC]
例如,当含有这两种片段的.htaccess文件被放置在www.oldexample的根目录下。 com,当有人要求:
www.oldexample.com/subdirectory/hello-world.php
他们应该被重定向到:
www.newexample.com/subdirectory/hello-world.php
。
在此先感谢!
我的答案是否适合你?也许你可以接受它。谢谢。 – SuperDuperApps