2013-07-24 26 views
0

我有次目录中的测试项目(G:/ WAMP/WWW /测试),它只有的index.php的.htaccess的.htaccess - 仅适用于的index.php /不/

我试图通过添加重写规则为.htaccess这样做友好的URL:

RewriteEngine on 

DirectoryIndex index.php 

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_FILENAME} !-d 

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 

RewriteRule ^/*$ index.php 

这个工作对所有其他项目,但它不工作在这一个。当我要访问一个像这样的URL:

http://localhost/test/TESTING_URL我得到默认404未找到页。但是,如果我这样走:http://localhost/test/index.php/TESTING_URL - 它的工作原理。

Apache的错误日志是给我下面的错误:

File does not exist: G:/wamp/www/test/TESTING_URL 

回答

0

以下为我工作:

RewriteEngine on 

RewriteBase /test/ 

DirectoryIndex index.php 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 
RewriteRule ^/*$ index.php 

确保此.htaccess文件所在的目录test并有AREN在更高级别的任何.htaccess文件中没有任何冲突的重写规则。

否则唯一的区别是添加了RewriteBase行。

+0

我仍然** ** 404找不到**错误 –

+0

如何添加RewriteBase? (我刚刚编辑我的答案) – Octopus

+0

仍然发生同样的事 –

相关问题