gpt4 book ai didi

php - .htaccess 301 重定向和删除 .html 合并

转载 作者:搜寻专家 更新时间:2023-10-31 20:38:02 24 4
gpt4 key购买 nike

我正在尝试将所有 .html 文件从 stripelatice_ui 文件夹重定向到根目录并删除 .html 扩展名

localhost:8089/stripelatice_ui/home.html

localhost:8089/home

我试过用

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [QSA,NC,L]


RewriteRule ^stripelatice_ui/(.*)$ /$1 [R=301,NC,L]

但是它给出了一个错误,说该页面有重定向循环

最佳答案

您可以使用:

RewriteEngine On
RewriteBase /stripelatice_ui/

# To externally redirect /stripelatice_ui/file.html to /file
RewriteCond %{THE_REQUEST} /stripelatice_ui/(.+?)\.html[\s?] [NC]
RewriteRule ^ /%1 [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)/?$ $1.html [L]

关于php - .htaccess 301 重定向和删除 .html 合并,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30433469/

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