gpt4 book ai didi

regex - 如何将 www 加入到非 www 重写规则与现有

转载 作者:行者123 更新时间:2023-12-01 23:54:44 25 4
gpt4 key购买 nike

我正在尝试将 www 添加到非 www 重写到现有的:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

我试过:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

#Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

如何加入这两个重写规则?

最佳答案

您可以使用:

RewriteEngine On

#Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

关于regex - 如何将 www 加入到非 www 重写规则与现有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24539373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com