简体   繁体   English

.htaccess 301重定向并删除.html组合

[英].htaccess 301 redirect and remove .html combined

I am trying to redirect all .html files form stripelatice_ui folder to root and remove .html extention 我试图将所有.html文件从stripelatice_ui文件夹重定向到root并删除.html扩展名

localhost:8089/stripelatice_ui/home.html

to

localhost:8089/home

i have tried using 我试过用

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


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

but it is giving be error saying that the page has redirection loop 但它是错误的说该页面有重定向循环

You can use: 您可以使用:

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM