redirect subdomain and retain url structure

老子叫甜甜 提交于 2019-12-21 21:03:43

问题


I'm redirecting a wordpress blog that lived in a subdomin to my root. when i visit links from my old blog, they just redirect to the index page of my blog, but i need them to redirect to the actual post. for example -

sub.mysite.com/1/2/3 - should redirect to -  mysite.com/sub/1/2/3

how can this be done? thanks!

UPDATE - still haven't found a solution for this. Anyone?

OR is there another post here that already exists that will show me the correct way to do this? THANKS!


回答1:


The alternative approach is by editing your web server configuration.

Apache's rewrite rules can do this. You most likely have a .htaccess file in the root directory of your blog. Append the text below to it. If there is no such file, create one.

RewriteEngine On
RewriteCond %{HTTP_HOST} sub.mysite.com
RewriteRule ^(.*)$ http://mysite.com/sub$1 [R=permanent,L]

Your web server has to be configured to accept this configuration from a .htaccess file. It can also be placed in the configuration directly. The procedure for this differs depending on your web host.




回答2:


The Wordpress Redirection plugin should be able to do exactly what you need.

If it doesn't, you can also accomplish this using your web server's configuration, but it's more complex to set up. See my second answer on this page.



来源:https://stackoverflow.com/questions/7475249/redirect-subdomain-and-retain-url-structure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!