mod_rewrite隐藏了url的一部分

时间:2010-12-22 01:46:10

标签: apache .htaccess mod-rewrite

嘿伙计们,我做了一堆谷歌搜索,但我无法弄清楚如何让mod_rewrite为我的目的工作。

这是我的网址:

http://localhost/symfony2/web/index.php

我想隐藏web/index.php部分,以便:

http://localhost/symfony2/web/index.php/hello/bob

转向:

http://localhost/symfony2/hello/bob

现在似乎没什么用。它只是一直显示我的文件夹结构。这是我现在拥有的:

RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) localhost/symfony2/web/index.php$1 [L]

(也发布在http://forum.symfony-project.org/viewtopic.php?f=23&t=31361。)

1 个答案:

答案 0 :(得分:0)

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

!-f!-d是为了确保如果文件或目录匹配,则不会重写它。)

相关问题