0

我的目标很简单:

  1. 任何事情都/special应该去/SpecialHandler.php
  2. 其他一切都应该去/index.php

我的基本配置是这样写的,但它不起作用:

RewriteEngine on
RewriteBase /
RewriteRule ^/special(.*)/?$ SpecialHandler.php [L,NC]
RewriteRule ^.*/?$ index.php [L]

以下是正在发生的事情:

  • 本地主机 - 工作正常
  • localhost/bla_bla-bla%20bla - 工作正常
  • localhost/special/ -index.php而不是SpecialHandler.php
  • localhost/special/fu/bar/bat - index.php而不是SpecialHandler.php

这一定是我想念的明显东西。

4

1 回答 1

1

删除特殊规则的第一个 / :

RewriteRule ^special(.*)/?$ SpecialHandler.php [L,NC]

它应该工作

-- 完成工作 htaccess

RewriteEngine on
RewriteBase /a/
RewriteRule ^special(.*)/? SpecialHandler.php [NC,L]
RewriteRule ^.*/?$ index.php [L]

网址:

http://localhost/a/special => special
http://localhost/a/special/really => special
http://localhost/a/index.php => index
http://localhost/a/foobarbaz => index
于 2012-12-18T18:24:25.870 回答