【问题标题】:mod rewrite in Expression Engine: removing directory in URL表达式引擎中的 mod 重写:删除 URL 中的目录
【发布时间】:2009-08-21 21:17:09
【问题描述】:

我在表达式引擎 CMS 中工作,我有一些重写代码来从 URL 中删除 index.php,但在我的某些 URL 上,我想删除文件名之前的目录 /site/

就像我有/site/pennsylvania_attorneys.html

我想删除站点部分并让它阅读/pennsylvania_attorneys.html

我现在拥有的当前mod重写代码是:

RewriteEngine on
RewriteCond $1 !^(images|css|themes|tools|admin|inc|js|cgi-bin|swf|themes|pennsylvania_attorneys_tpl\.html|license\.txt|attorney-tpl\.html|favicon\.ico|robots\.txt|index\.php) [NC]
RewriteRule ^(.*)$ /index.php/$1 [L]

有什么想法吗?

【问题讨论】:

    标签: url mod-rewrite


    【解决方案1】:

    试试这些规则:

    RewriteCond %{THE_REQUEST} ^GET\ /site/
    RewriteRule ^site/(.*) /$1 [L,R=301]
    RewriteRule !^site/ site%{REQUEST_URI}
    

    这会将/site/… 的任何请求从外部重定向到/…,如果请求丢失,则在内部重新附加它。

    【讨论】:

      【解决方案2】:

      你可以删掉所有这些,然后简单地这样做:

      
      RewriteEngine On
      RewriteRule ^.*$ site/$0 [L,QSA]
      

      而且您不必从 URL 中“删除”index.php,您永远不能把它放在那里。应该工作得很好。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-10-12
        • 1970-01-01
        • 2011-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-29
        • 1970-01-01
        相关资源
        最近更新 更多