【问题标题】:Rewrites in htaccess not hiding filename在 htaccess 中重写不隐藏文件名
【发布时间】:2015-11-18 16:42:07
【问题描述】:

我有一个网站,我正在重写 URL 以使用文件 package.php,但使用 URL http://example.com/package-type/airport/hotel-name。转到页面时它工作正常。但是,Google 网站管理员工具会报告 URL http://example.com/package.php?/package-type/airport/hotel-name 的错误。为什么我的 htaccess 重写对 Google 不起作用?这是我在 htaccess 文件中的重写代码:

#Redirects hotel pages to package.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /package.php?/$1 [L]

# Removes package.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*package\.php [NC]
RewriteCond %{REQUEST_URI} !/.* [NC]
RewriteRule (.​*?)package\.php/*(.*​) /$1$2 [R=301,NE,L]

任何帮助将不胜感激。

【问题讨论】:

    标签: .htaccess url mod-rewrite url-rewriting


    【解决方案1】:

    有这样的规则:

    # Removes package.php from ExpressionEngine URLs
    RewriteCond %{THE_REQUEST} /package\.php\?(\S+)\s [NC]
    RewriteRule ^ /%1? [R=301,NE,L]
    
    #Redirects hotel pages to package.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /package.php?/$1 [L,QSA]
    

    【讨论】:

    • 这看起来可行。但我要到 11 月 23 日星期一才能对其进行测试。
    猜你喜欢
    • 2016-02-28
    • 1970-01-01
    • 2013-04-02
    • 2015-09-12
    • 1970-01-01
    • 1970-01-01
    • 2022-01-02
    • 1970-01-01
    • 2011-04-12
    相关资源
    最近更新 更多