简体   繁体   English

访问主网址后,如何重定向到wordpress子目录?

[英]How to redirect to wordpress sub directory when primary url is accessed?

I am installing a wordpress site in sub-directory of my existing site. 我正在现有网站的子目录中安装一个wordpress网站。 is there a way to edit the settings in wordpress so that when i type in my primary URL (ie www.main.com) it automatically reroutes to www.main.com/subdirectory? 有没有一种方法可以在wordpress中编辑设置,以便当我输入主URL(即www.main.com)时,它会自动重新路由到www.main.com/subdirectory?

WordPress doesn't control the part of your site it is not installed in. However, one answer would be to use a PHP redirect in your index.php in the root of your site. WordPress不能控制未安装站点的部分。但是,一个答案是在站点根目录的index.php中使用PHP重定向。

index.php would look like this: index.php看起来像这样:

<?php header("Location: http://www.yoursite.com/your_blog"); ?>

If you put that line as the only line in your index.php in the root of your site, it will redirect. 如果将该行作为站点根目录中index.php中的唯一行,它将进行重定向。 Obviously, replacing the URL with the real URL to your blog. 显然,将URL替换为博客的真实URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM