我想将此网址重写为:sample.com/panel/index.php/api/users?page=1
至sample.com/panel/api/users?page=1
(删除index.php
)
这是我的.htaccess
文件:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
但这不起作用!为什么?
我在ubuntu中使用apache2 ver 2.4
答案 0 :(得分:1)
您是否检查过mod_write是否已启用?:sudo a2enmod rewrite
您是否检查过允许虚拟主机使用.htaccess?在您的虚拟主机配置中需要AllowOverride all
。