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/0/azure/12.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 - Fatal编程技术网

如何使用.htaccess将所有页面重定向到除主页以外的其他域

如何使用.htaccess将所有页面重定向到除主页以外的其他域,.htaccess,.htaccess,我想将所有页面(主页除外)从一个域重定向到另一个域 如何执行此操作?这是您必须添加到htaccess文件中的规则 RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] #if not root RewriteCond %{REQUEST_URI} !^/?$ [NC] #redirect RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=

我想将所有页面(主页除外)从一个域重定向到另一个域


如何执行此操作?

这是您必须添加到htaccess文件中的规则

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
#if not root
RewriteCond %{REQUEST_URI} !^/?$ [NC]
#redirect
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

这是您必须添加到htaccess文件中的规则

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
#if not root
RewriteCond %{REQUEST_URI} !^/?$ [NC]
#redirect
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]

你能添加你主页上的示例链接吗?主页应该是
example.com/
。干杯,欢迎来到Stack Overflow!我尽我所能地编辑了你的问题。但是,请添加代码和说明,以便更多了解该主题的人能够看到它。请在遇到的特定错误消息中进行编辑,以防识别特定问题。祝你好运你能添加你主页上的示例链接吗?主页应该是
example.com/
。干杯,欢迎来到Stack Overflow!我尽我所能地编辑了你的问题。但是,请添加代码和说明,以便更多了解该主题的人能够看到它。请在遇到的特定错误消息中进行编辑,以防识别特定问题。祝你好运