簡體   English   中英

.htaccess 301重定向並刪除.html組合

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

我試圖將所有.html文件從stripelatice_ui文件夾重定向到root並刪除.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]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM