简体   繁体   中英

.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

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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