【问题标题】:Remove .html extension from url using .htaccess giving 403 forbidden error in some urls使用 .htaccess 从 url 中删除 .html 扩展名,在某些 url 中给出 403 禁止错误
【发布时间】:2014-10-09 03:04:42
【问题描述】:
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.

【问题讨论】:

标签: php html apache .htaccess mod-rewrite


【解决方案1】:

答案:

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

每Trouble removing .html URL extension using .htaccess

【讨论】:

    猜你喜欢
    • 2020-02-27
    • 1970-01-01
    • 2015-12-31
    • 2022-01-21
    • 2018-07-28
    • 2015-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多