2017-07-24 142 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