Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.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
如何从子目录重定向到直接Url?via.Htaccess_.htaccess_Cpanel - Fatal编程技术网

如何从子目录重定向到直接Url?via.Htaccess

如何从子目录重定向到直接Url?via.Htaccess,.htaccess,cpanel,.htaccess,Cpanel,我的问题是: 我想从以下位置重定向: domain.com/blog/how-to-stuffs/ 致: domain.com/how-to-stuffs/ 请共享.htaccess代码,以执行此类重定向。谢谢。尝试: Redirect "/blog/how-to-stuffs/" "/how-to-stuffs/" 或者,仅当上述方法无效时才使用此选项 RewriteEngine On RewriteBase / RewriteCond %{REQUE

我的问题是:

我想从以下位置重定向:

domain.com/blog/how-to-stuffs/

致:

domain.com/how-to-stuffs/

请共享.htaccess代码,以执行此类重定向。谢谢。

尝试:

Redirect "/blog/how-to-stuffs/" "/how-to-stuffs/"
或者,仅当上述方法无效时才使用此选项

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^\/blog\/how-to-stuffs\/?$
RewriteRule ^ /how-to-stuffs/ [R=302,L]

实际上,我想对大量的URL做同样的处理,就像站点中的所有URL一样,所以我必须为每个URL手动执行此操作?请提供帮助。@RaviSharma,若您想为站点中的所有URL执行此操作,可以一次性完成。如果您想使用大量URL,您应该手动包含所有URL,或者排除您不想重定向的URL
redirect 301/blog/https://example.com/
应该重定向
/blog/*
中的所有URL。