Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess将目录重定向到单个页面_.htaccess_Redirect_Url Rewriting_Web - Fatal编程技术网

.htaccess将目录重定向到单个页面

.htaccess将目录重定向到单个页面,.htaccess,redirect,url-rewriting,web,.htaccess,Redirect,Url Rewriting,Web,我想将.com/blog目录中的所有页面重定向到.com/error目录 我搜索了网页,找到了很多不同的方法,但我希望它重定向到一个单一的页面 我尝试过的所有东西都重定向到相同的文件名,但在不同的目录中。例如,.com/blog/index.nonexisting重定向到.com/error/index.nonexisting 我希望第一个目录中的所有文件都重定向到某个文件,因此如果您转到.com/blog/whatever.php,它将转到.com/error/index.php,如果您转到.

我想将
.com/blog
目录中的所有页面重定向到
.com/error
目录

我搜索了网页,找到了很多不同的方法,但我希望它重定向到一个单一的页面

我尝试过的所有东西都重定向到相同的文件名,但在不同的目录中。例如,
.com/blog/index.nonexisting
重定向到
.com/error/index.nonexisting

我希望第一个目录中的所有文件都重定向到某个文件,因此如果您转到
.com/blog/whatever.php
,它将转到
.com/error/index.php
,如果您转到
.com/blog/random.xml
,您将被重定向到
.com/error/index.php


有什么方法可以做到这一点吗?

试着把它放在你的.htaccess中:

RewriteEngine on
RewriteRule ^blog/(.+) error/index.php [L,R]

如果需要301重定向,请将
R
替换为
R=301
,如果不需要外部重定向,请将
R
完全删除。

在wordpress中,我将其用于多站点上的subdmoain

因此,“subdomain.domain.org/wp_super_faq/anyandalltextantall”将重定向到“subdomain.domain.org/faq”


朋友我想301重定向我的全部博客文件夹到主url。当有人指向我的博客链接时,它会自动重定向到主页。使用htaccess。谢谢,谢谢!!你节省了我很多时间
RewriteCond %{HTTP_HOST} ^subdomain\.domain\.org [NC]
RewriteRule ^wp_super_faq.*$ https://subdomain\.domain\.org/faqs/ [R=301,L]