已被 301 重定向的域的重定向 URL
Redirect URLs of Domain that is already 301 Redirected
我什至不知道如何正确地问这个问题,因为我以前从未见过这样的问题。我非常擅长编辑名称服务器、创建记录和 cname 等,但我不知道这是否可行。
我有一个客户拥有多个域,这些域都指向同一个站点。所以说主域名是 www.client-site.com. 那么 www.other-domain-1.com 和 www.other-domain-2.com 只是设置为 301 重定向指向 www.client-site.com。
所以到目前为止一切都很好,他正在请求 www.other-domain-1.com/facebook 和 www.other-domain-1.com/linkedin 指向他的 facebook 页面或 linkedin 个人资料,而不是重定向到主域。
301 重定向发生在注册商处,我认为没有办法从那里做他想做的事。但我想我可以改为将它指向网络主机名称服务器并将其作为附加域包含在内,然后使用 .htaccess 文件仅对主机名进行 301 重定向,然后根据需要重定向 hostname/paths .
那么正确的做法是什么?像...
Redirect 301 http://other-domain-1.com/facebook http://facebook.com/account
Redirect 301 http://other-domain-1.com/linkedin http://linkedin.com/profile
Redirect 301 http://other-domain-1.com http://client-site.com
您可以在 DOCUMENT_ROOT/.htaccess
文件中使用此代码:
RewriteEngine On
# facebook redirect
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^facebook/?$ http://facebook.com/account [L,NC,R=302]
# linked-in redirect
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^linkedin/?$ http://linkedin.com/profile [L,NC,R=302]
# rest of the redirects
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^ http://client-site.com%{REQUEST_URI} [L,NE,R=302]
因此,基于上面的 anubhava 回答,在我的服务器上工作的解决方案是
facebook redirect
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^facebook/?$ http://facebook.com/account [L,NC,R=302]
然后在让它们全部工作后将 R=302
更改为 R=301
以使重定向永久化。
我什至不知道如何正确地问这个问题,因为我以前从未见过这样的问题。我非常擅长编辑名称服务器、创建记录和 cname 等,但我不知道这是否可行。
我有一个客户拥有多个域,这些域都指向同一个站点。所以说主域名是 www.client-site.com. 那么 www.other-domain-1.com 和 www.other-domain-2.com 只是设置为 301 重定向指向 www.client-site.com。
所以到目前为止一切都很好,他正在请求 www.other-domain-1.com/facebook 和 www.other-domain-1.com/linkedin 指向他的 facebook 页面或 linkedin 个人资料,而不是重定向到主域。
301 重定向发生在注册商处,我认为没有办法从那里做他想做的事。但我想我可以改为将它指向网络主机名称服务器并将其作为附加域包含在内,然后使用 .htaccess 文件仅对主机名进行 301 重定向,然后根据需要重定向 hostname/paths .
那么正确的做法是什么?像...
Redirect 301 http://other-domain-1.com/facebook http://facebook.com/account
Redirect 301 http://other-domain-1.com/linkedin http://linkedin.com/profile
Redirect 301 http://other-domain-1.com http://client-site.com
您可以在 DOCUMENT_ROOT/.htaccess
文件中使用此代码:
RewriteEngine On
# facebook redirect
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^facebook/?$ http://facebook.com/account [L,NC,R=302]
# linked-in redirect
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^linkedin/?$ http://linkedin.com/profile [L,NC,R=302]
# rest of the redirects
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^ http://client-site.com%{REQUEST_URI} [L,NE,R=302]
因此,基于上面的 anubhava 回答,在我的服务器上工作的解决方案是
facebook redirect
RewriteCond %{HTTP_HOST} ^(www\.)?other-domain-1\.com$ [NC]
RewriteRule ^facebook/?$ http://facebook.com/account [L,NC,R=302]
然后在让它们全部工作后将 R=302
更改为 R=301
以使重定向永久化。