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
如何使用.htaccess Apache指令将整个目录重定向到其他域_.htaccess_Redirect - Fatal编程技术网

如何使用.htaccess Apache指令将整个目录重定向到其他域

如何使用.htaccess Apache指令将整个目录重定向到其他域,.htaccess,redirect,.htaccess,Redirect,我在文档根目录下名为“重定向”的.htaccess文件中有以下指令: 但是当我登录到http://current.domain.com/redirect(.htaccess文件的主页)结果是找不到页面,URL显示: https://new.domain.com/forms/test/index.phpredirect 这是为什么/如何发生的?您应该使用mod_rewrite而不是匹配精确的URI模式,因为它支持正则表达式匹配 RewriteEngine On RewriteBase /redi

我在文档根目录下名为“重定向”的.htaccess文件中有以下指令:

但是当我登录到
http://current.domain.com/redirect
(.htaccess文件的主页)结果是找不到页面,URL显示:

https://new.domain.com/forms/test/index.phpredirect

这是为什么/如何发生的?

您应该使用
mod_rewrite
而不是匹配精确的URI模式,因为它支持正则表达式匹配

RewriteEngine On
RewriteBase /redirect/

RewriteRule ^$ https://new.domain.com/forms/test/index.php [L,R=301]
RewriteEngine On
RewriteBase /redirect/

RewriteRule ^$ https://new.domain.com/forms/test/index.php [L,R=301]