我只想将基本网址重定向到外部网站。
例如,我希望将 example.com
重定向到 anotherdomain.com
,但我不希望 example.com/path
重定向。
到目前为止,example.com/path
重定向到 anotherdomain.com/path
。 :(
编辑:
首先感谢您的帮助! example.com 现在重定向到 another.com,而不影响 example.com 的子路径。
但是,理想情况下,m.example.com
不会重定向到 another.com
。所以它实际上只是 example.com
重定向到 another.com
。
最佳答案
将此添加到 DocumentRoot
中的 .htaccess
中。我假设您在服务器上仅托管一个域。
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^m\.
RewriteRule ^$ http://anotherdomain.com [R,L]
关于apache - 仅使用 htaccess 重定向基本 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9418765/