【问题标题】:Removing .html/.php from url with apache conf使用 apache conf 从 url 中删除 .html/.php
【发布时间】:2015-06-09 22:14:30
【问题描述】:

我设法通过 htaccess 文件删除了 .extension,但我想知道是否可以通过 apache2.conf 或其他文件而不使用 .htaccess 文件。

经验

example.com/example

而不是

example.com/example.html

【问题讨论】:

    标签: apache .htaccess configuration


    【解决方案1】:

    您可以在 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]
    

    【讨论】:

    • 那些不适用于 apache conf。它给了我一个错误。这些规则不是 .htaccess 的吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-11
    • 2012-01-24
    • 2013-05-09
    • 2013-04-01
    • 1970-01-01
    • 2010-09-09
    • 1970-01-01
    相关资源
    最近更新 更多