2014-05-06 28 views
0

我有一个php文件数量的自定义文件夹。我想通过从URL中删除.php来创建一个友好的URL。因此,我在自定义文件夹中创建了.htaccess文件,其中所有的.php文件位于并写入了下面的代码,但它不起作用。将url更改为友好的网址php

我的网址是:magento/cl/unilever.php

预期网址:magento/cl/unilever

的.htaccess包含:

Options +FollowSymLinks 
RewriteEngine On 
RewriteRule ^unilever $ unilver.php 

回答

0

假设你想重写只是单独的目录,试试这个:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(\w*)$ $1.php [L] 
+0

我已将此代码复制到.htaccess,它不起作用 – user2720197

+0

我测试过了,它正在工作。 'mod_rewrite'是否被启用?或者它只是重写规则不起作用? –

+0

mod_rewrite已启用,重写在此处不起作用 – user2720197