0
我已经尝试了几种方法在我的.htaccess文件中添加两条规则,但我无法得到它的工作。删除目录名称和php文件扩展名
我想删除.php文件扩展名,但我也想删除目录/页面出现在URL中。
我的目录结构是这样的:
/
-/errors/
--/401.php
-/pages/
--/home.php
--/about.php
--/contact.php
-/includes/
--/header.php
--/footer.php
我的.htaccess文件是这样的:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
ErrorDocument 404 /errors/404.php
我应该写在我的.htaccess文件,使工作?
我曾尝试以下,但它似乎并没有工作:
RewriteRule ^pages(/.*|)$ $1 [L,NC]
不,它没有! :(我得到一个404,如果我尝试domain.com/contact例如:( –
我设法做到这一点:'RewriteRule^about.php $ /pages/about.php RewriteRule^contact.php $/pages/contact.php',但我无法找到如何做到这一点所有的PHP文件/页面 –
现在尝试我的更新规则从网站根.htaccess – anubhava