我正在尝试将所有 .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/