Url重写以从所有项目文件中隐藏.html和.php


Url rewriting to hide .html and .php from all project files

我的项目中有几个页面,它们是:

index.php
aboutus.php
signup.html
login.html

我想在url中显示而不显示.php或.html我试过这个代码:

RewriteEngine On
RewriteCond %{http://www.example.net/project name/index.php} !-f
RewriteRule ^([^'.]+)$ $1.php [NC,L]
RewriteRule ^([^'.]+)$ $1.html [NC,L]

这不起作用

尝试为我工作

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f [NC] 
RewriteRule ^(.*?)$ $1.php [L]
RewriteCond %{REQUEST_FILENAME}.html -f [NC] 
RewriteRule ^(.*?)/?$ $1.html [L]
RewriteEngine on
RewriteBase /
RewriteCond %{http://www.ameryprod.com/index.html} !('.[^./]+)$
RewriteCond %{REQUEST_fileNAME} !-d
RewriteCond %{REQUEST_fileNAME} !-f
RewriteRule (.*) /$1.html [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}' /([^.]+)'.html' HTTP
RewriteRule ^([^.]+)'.html$ http://www.ameryprod.com/$1 [R=301,L]

最后我找到了这个解决方案,希望它对你也有效。