【发布时间】:2015-06-09 22:14:30
【问题描述】:
我设法通过 htaccess 文件删除了 .extension,但我想知道是否可以通过 apache2.conf 或其他文件而不使用 .htaccess 文件。
经验
example.com/example
而不是
example.com/example.html
【问题讨论】:
标签: apache .htaccess configuration
我设法通过 htaccess 文件删除了 .extension,但我想知道是否可以通过 apache2.conf 或其他文件而不使用 .htaccess 文件。
经验
example.com/example
而不是
example.com/example.html
【问题讨论】:
标签: apache .htaccess configuration
您可以在 Apache conf 文件中使用这两条规则:
RewriteCond %{THE_REQUEST} \s/+(.+?)\.html[\s?] [NC]
RewriteRule ^ /%1 [R=302,L,NE]
# To internally forward /dir/file to /dir/file.html
RewriteCond %{DOCUMENT_ROOT}/$1\.html -f [NC]
RewriteRule ^(.+?)/?$ $1.html [L]
【讨论】: