Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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
Apache 301使用.htaccess从文件夹重定向到根目录_Apache_.htaccess_Mod Rewrite_Url Redirection - Fatal编程技术网

Apache 301使用.htaccess从文件夹重定向到根目录

Apache 301使用.htaccess从文件夹重定向到根目录,apache,.htaccess,mod-rewrite,url-redirection,Apache,.htaccess,Mod Rewrite,Url Redirection,我需要将所有url从子文件夹重定向到根目录: http://www.example.com/blabla/some-url to http://www.example.com/some-url 我的.htaccess代码是: RewriteCond %{HTTP_HOST} ^http\:\/\/www\.example\.com\/blabla$ RewriteRule ^/?$ "http\:\/\/www\.example\.com\/" [R=301,L] 但不是为我工作 您与错误

我需要将所有url从子文件夹重定向到根目录:

http://www.example.com/blabla/some-url
to
http://www.example.com/some-url 
我的.htaccess代码是:

RewriteCond %{HTTP_HOST} ^http\:\/\/www\.example\.com\/blabla$
RewriteRule ^/?$ "http\:\/\/www\.example\.com\/" [R=301,L]

但不是为我工作

您与错误的参数匹配

RewriteEngine On
RewriteRule ^/?blabla/(.*)$ /$1 [R=301,L]

也可以使用重定向匹配指令

RedirectMatch 301 ^/folder/(.+)$ http://example.com/$1
这将301重定向到/foobar/foobar