【问题标题】:Issues with my htaccess - rewriting user我的 htaccess 问题 - 重写用户
【发布时间】:2015-09-06 17:24:23
【问题描述】:

用最简单的术语来说,我试图将用户从 faq.html 重定向到 Help/Frequently-Asked-Questions。现在下面的代码部分工作。从某种意义上说,url 确实显示了干净的 url,但是找不到 faq.html 页面本身,因为干净的 url 在重写时充当了它自己的页面。

任何帮助将不胜感激。

# Activate rewrite engine

RewriteEngine On

# Establish the base
RewriteBase /

# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /faq.html [NC]
RewriteRule ^ Help/Frequently-Asked-Questions [R=302,L,NE]

# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^faq.html$ help/Frequently-Asked-Questions [L,QSA]

【问题讨论】:

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


    【解决方案1】:

    你的第二条规则是反向的。这样做:

    RewriteEngine On
    RewriteBase /
    
    # external redirect from actual URL to pretty one
    RewriteCond %{THE_REQUEST} /faq\.html [NC]
    RewriteRule ^ Help/Frequently-Asked-Questions [R=302,L]
    
    # internal forward from pretty URL to actual one
    RewriteRule ^help/Frequently-Asked-Questions/?$ faq.html [L,NC]
    

    【讨论】:

      猜你喜欢
      • 2016-07-01
      • 2013-07-22
      • 2011-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多