【问题标题】:htaccess rewrite everything but index and roothtaccess 重写除索引和根目录之外的所有内容
【发布时间】:2011-03-11 18:38:29
【问题描述】:

我正在尝试建立一个站点,它将除根目录和索引之外的所有内容都转发到变量中。我现在已经像这样设置了 htaccess 文件:

Options +FollowSymlinks
RewriteEngine on

RewriteRule -(.*)$ http://blah.com/blah.php?name=$1 [R,NC]

只是为了使索引正常工作,并且以连字符(-)开头的任何内容都会被重写

我希望能够重写索引文件以外的任何内容,并且仍然允许通过 blah.com 和 blah.com/ 访问索引文件

有什么想法吗?

【问题讨论】:

    标签: .htaccess indexing root


    【解决方案1】:

    如果您仍然没有弄清楚这一点,这应该可以:

    RewriteCond %{REQUEST_URI} !^(/|/index.php|/blah.php)$
    RewriteRule ^(.*)$ blah.php?name=$1 [R]
    

    【讨论】:

      【解决方案2】:

      试试这个:

      RewriteCond %{REQUEST_URI}   !^/index.php$
      RewriteCond %{REQUEST_URI}   !^/blah.php
      RewriteCond %{REQUEST_URI}   !^$
      RewriteRule ^(.*)         http://blah.com/blah.php?name=$1 [R,NC]
      

      【讨论】:

      • 这给了我一个重定向循环
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-23
      • 2010-10-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多