【问题标题】:Redirect not .html url to .html in joomla在joomla中将不是.html url重定向到.html
【发布时间】:2018-02-15 01:37:54
【问题描述】:

我需要通过 htaccess 将非 .html url 重定向到 .html url。

例如我的 url 是 http://domainname.com/contact-ushttp://domainname.com/contact-us.html 两个 url 开放。但我的要求是将http://domainname.com/contact-us 重定向到http://domainname.com/contact-us.html

我正在尝试以下代码,但它仍然无法正常工作。

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ /$1 [R,L]

【问题讨论】:

    标签: .htaccess redirect joomla router


    【解决方案1】:

    你可以用这个:

    RewriteEngine on
    
    RewriteCond %{QEQUEST_FILENAME}.html -f
    RewriteRule ^ %{REQUEST_URI}.html [L,R]
    

    这将首先检查文件(请求的uri)是否存在并且是一个常规的html文件,如果存在,那么规则会将/file重定向到/file.html强>。

    【讨论】:

    • 请定义“它不工作”。您使用此代码遇到什么错误
    • 我已按原样放置此代码,但它不适用于我们的页面。所有页面都使用非 .html 和 .html 打开
    猜你喜欢
    • 2018-06-11
    • 2013-05-03
    • 2010-09-25
    • 2013-02-06
    • 2014-10-11
    • 1970-01-01
    • 2011-02-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多