我在Apache2 localhost(linux)上有一个工作路径:
http://localhost/lab/silex/web/index.php/hello/name
我想成为:
http://localhost/lab/silex/hello/name
现在我启用并测试了重写模式.
我已将.htaccess文件放在我的silex/web文件夹中:
Options -MultiViews RewriteEngine On RewriteBase /web/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L]
我仍然看不到干净的网址工作.
在你的主文件夹中试试这个:(对你来说这将是silex文件夹)
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ web/$1 [QSA,L] </IfModule>
并在网络文件夹中:
<IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] RewriteCond %{THE_REQUEST} ^(GET|HEAD)\ /web/ RewriteRule ^(.*)$ /$1 [L,R=301] </IfModule>