gpt4 book ai didi

regex - 动态域 htaccess 重定向

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

我在 htaccess 文件中创建了 www 域重定向:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
ErrorDocument 404 /

一切正常,但我不想每次都手动输入域名。
如何将example.com改成动态域名?
有人可以帮助我吗?

最佳答案

您可以使用:

ErrorDocument 404 /
RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L,NE]

关于regex - 动态域 htaccess 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28213926/

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