.htaccess默认重写几次

时间:2016-05-24 10:47:45

标签: php apache .htaccess mod-rewrite

您好我的htaccess文件有问题,我想将调用重定向到不同的文件,如果调用默认情况下重定向不匹配到index.php

这是我的htaccess:

Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /public
  RewriteCond %{REQUEST_FILENAME} !-f

  RewriteRule ^callOne(|/.*)$ callOnephp?q=$1 [L,QSA]
  RewriteRule ^callTwo(|/.*)$ callTwo.php?q=$1 [L,QSA]

  RewriteRule ^(.*)$ index.php [L,QSA]
</IfModule>

因此,如果调用/ callOne,名为callOne.php的文件将响应,但如果不响应,则会通过index.php回答该调用。如果调用callTwo,名为callTwo.php的文件将响应,否则index.php将默认响应。

目前,电话始终由index.php回答。我该如何解决这个问题?

提前致谢!

1 个答案:

答案 0 :(得分:0)

这应该有效:

RewriteEngine On
RewriteBase /

RewriteRule ^call(One|Two)$ call$1.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L,QSA]