Url 仅当文件夹存在时才重定向到该文件夹

Url redirect to folder only if it exist

我想使用 Url 重写来转换它:

http://test.com/mypage

我已经有了 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/ [L,R=301]

RewriteCond %{DOCUMENT_ROOT}/.php -f
RewriteRule ^(.*?)/?$ .php [L]

RewriteCond %{DOCUMENT_ROOT}/.html -f
RewriteRule ^(.*?)/?$ .html [L]

Options -Indexes

您可以使用:

ErrorDocument 404 /404.php

Options +FollowSymLinks -Indexes
RewriteEngine on

RewriteCond %{HTTP_HOST}  ^www\.(test\.net)$ [NC]
RewriteRule ^(.*) http://%1/ [L,R=301]

RewriteCond %{DOCUMENT_ROOT}/.php -f
RewriteRule ^(.+?)/?$ .php [L]

RewriteCond %{DOCUMENT_ROOT}/.html -f
RewriteRule ^(.+?)/?$ .html [L]

RewriteCond %{DOCUMENT_ROOT}/pages/.php -f
RewriteRule ^(.+?)/?$ pages/.php [L]