gpt4 book ai didi

apache - 将 documentroot 重定向到 conf apache 或 .htccess 中的另一个文件夹

转载 作者:可可西里 更新时间:2023-11-01 16:29:28 26 4
gpt4 key购买 nike

美好的一天

我想在请求子目录时重写一个url当用户请求时

172.0.0.1/url

我想重写使这个 url 指向

172.0.0.1/url/url

或者 documentroot 在/var/www/html/url/url 中指向

172.0.0.1/url

最佳答案

这里的技巧是避免创建重写和重定向循环。您可以将此代码放在根文件夹 htaccess 中

RewriteEngine On

# Redirect /url/url/xxx to /url/xxx
RewriteCond %{THE_REQUEST} \s/(url)/url/(.*)\s [NC]
RewriteRule ^ /%1/%2 [R=301,L]

# Internally rewrite back /url/xxx to /url/url/xxx
RewriteRule ^(url)/((?!url/).*)$ /$1/$1/$2 [L]

关于apache - 将 documentroot 重定向到 conf apache 或 .htccess 中的另一个文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55287660/

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