1

我正在设置一个 php mvc 框架,我想将域之后的任何内容重定向到 index.php/$1 但它不起作用。我启用了 rewrite_module 和 AllowOverride All,我还缺少什么吗?

基本上我希望 url 从这个http://www.example.com/foo/bar到,http://www.example.com/index.php/foo/bar所以我可以从 $_SERVER['PATH_INFO']

这就是我所拥有的...

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>
4

2 回答 2

1

我相信您需要 /index.php 上的前导斜杠,因为您的正则表达式匹配行首。

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [L]
于 2011-07-05T23:32:17.153 回答
0

这是我的 httpd.conf 文件的问题。我在本地主机上没有 AllowOverride all。一旦我改变了一切正常。

于 2011-07-14T00:45:25.453 回答