I'm setting up a php mvc framework and I want to redirect anything aft开发者_高级运维er the domain to index.php/$1 but it's not working. I have rewrite_module enabled and AllowOverride All, is there something else I'm missing?
Basically I want the url to go from this http://www.example.com/foo/bar
to http://www.example.com/index.php/foo/bar
so I can grab it from $_SERVER['PATH_INFO']
Here's what I have...
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]
httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot c:/wamp/www
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/websites/snugglemvc"
ServerName www.snugglemvc.com
<Directory "c:/websites/snugglemvc">
Order Deny,Allow
Allow from all
AllowOverride all
</Directory>
</VirtualHost>
I believe you need the leading slash on /index.php as your regex matches beginning of line.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [L]
it was an issue with my httpd.conf file. i didn't have AllowOverride all on the localhost. once I changed that everything worked.
精彩评论