2017-07-24 146 views
0

我想重写我的PHP应用程序的网址,但它不工作。在Apache2网址重写不工作

我的目录结构

/var/www/html/test| 
        |---.htaccess 
        |---index.php 

我的.htaccess文件内容

# Activates URL rewriting (like myproject.com/controller/action/1/2/3) 
RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-d 

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_FILENAME} !-l 

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] 

apache2ctl -M结果:

rewrite_module (shared) 

Server版本:阿帕奇/ 2.4.18(Ubuntu的)

我在这个过程中做错了什么?请帮忙

+0

每当我尝试'本地主机/测试/某事/ something_more'它给出错误未找到。不应该重定向到index.php? –

+0

没有错误。但在我的'/ etc/apache2/apache2.conf'中''AccessFileName .htaccess'取消注释 –

回答

2

它现在工作正常。

我只是改变我的/etc/apache2/apache2.conf

<Directory /var/www/> 
    Options Indexes FollowSymLinks 
    AllowOverride None 
    Require all granted 
</Directory> 

<Directory /var/www/> 
    Options Indexes FollowSymLinks 
    AllowOverride ALL 
    Require all granted 
</Directory> 
+0

因此,'.htaccess'文件先前被禁用。 – MrWhite