簡體   English   中英

使用 .htaccess 從 url 中刪除 .html 擴展名,在某些 url 中給出 403 禁止錯誤

[英]Remove .html extension from url using .htaccess giving 403 forbidden error in some urls

Options -Indexes
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.html [NC]
RewriteRule ^ %1 [R,L,NC]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_FILENAME}.html [L]

在我的網站中,我使用此 .htaccess 代碼從 url 中刪除 .html 擴展名。 它在某些 url 中工作正常,但在某些 url 中會出現 403 禁止錯誤。 我檢查了這些網址的文件權限。 沒關系0644。

回答:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

每個使用 .htaccess 刪除 .html URL 擴展的麻煩

暫無
暫無

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

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