我想使用Url重写来转换它:
要
我已经有了ErrorDocument 404的一些代码,www。删除和删除.php和.html扩展名
ErrorDocument 404 http://test.net/404
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.test.net [NC]
RewriteRule ^(.*) http://test.net/$1 [L,R=301]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.*?)/?$ $1.html [L]
Options -Indexes
答案 0 :(得分:2)
您可以使用:
ErrorDocument 404 /404.php
Options +FollowSymLinks -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(test\.net)$ [NC]
RewriteRule ^(.*) http://%1/$1 [L,R=301]
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(.+?)/?$ $1.html [L]
RewriteCond %{DOCUMENT_ROOT}/pages/$1.php -f
RewriteRule ^(.+?)/?$ pages/$1.php [L]