[英]Url rewriting to hide .html and .php from all project files
我在我的项目中只有几页,它们是:
index.php
aboutus.php
signup.html
login.html
我想用以下代码在没有.php或.html的URL中显示:
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]
最终,我发现此解决方案希望它也对您有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.