Url rewrite is not working in some cases with XAMPP in Windows 7
I have a PHP website hosted at localhost on my Windows 7 PC, running XAMPP
1.8.2.
And I have rewrite rules as below:
Options -Indexes +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?rt=$1 [QSA,L]
</IfModule>
To rewrite the URL so it will always go into something like:
http://mysite.com/index.php?rt=[controller]/[action]/[params]
It works prefect until I found it failed when processing url like:
http://mysite.com/error/xxx. It returns a 404 status other than goes to
http://mysite.com/index.php?rt=error/xxx.
I carefully checked my PHP code and I am sure it is not the cause, and I
upload my website to a remote server and everything is fine. So I am
pretty sure something is not properly configured in my XAMPP (Apache),
that makes the /error/xxx request was treated differently.
Also I found visiting http://mysite.com/error/ gives me 403 but
http://mysite.com/[something_else]/ is fine.
Just in case, I paste my vhost.conf here as well:
<VirtualHost *:80>
DocumentRoot "/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "E:\htdocs\mysite.dev"
ServerName mysite.dev
</VirtualHost>
And related httpd.conf:
<Directory "E:\htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
Any help is appreciated!
No comments:
Post a Comment