在子目录中运行Wordpress(而不是根目录) [英] Running Wordpress in a subdirectory (not the root)

查看:169
本文介绍了在子目录中运行Wordpress(而不是根目录)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个wordpress网站正在我的网站的子目录中运行,基本上我的结构如下:
root / wp



我'd喜欢将wordpress的wp文件夹保存在同一个地方,但是它可以直接从根URL添加wordpress站点。



例如,当我去的时候网站加载到www.mysite.com/wp然而,我想让wordpress网站加载,当我只是去www.mysite.com - 目前,如果我去www.mysite.com它只是加载一个500内部服务器错误消息。



我希望我需要对htaccess文件进行一些更改 - 任何人都可以建议如何完成



简而言之,
当我访问www.mysite.com时,它会查看/ wp文件夹,但在地址栏中仍然显示为www.mysite.com。

解决方案

将这些行添加到.htaccess应该做这个工作(没有测试,对不起,可能还不够):

  RewriteEngine On 
RewriteCond%{HTTP_HOST} ^(www。)?mysite.com $
RewriteRule ^(/)?$ wp [L]

更新:您可能希望查看 https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory ,以实现更接近WordPress标准的方法。


I have a wordpress site that is currently running in a subdirectory of my website, basically put my structure is as follows: root/wp

I'd like to keep the wordpress wp folder in the same place however have it load the wordpress site directly from the root url.

For instance currently the site loads when I go to www.mysite.com/wp however I'd like to have the wordpress site load when I simply go to www.mysite.com - currently if I go to www.mysite.com it simply loads an 500 Internal Server Error message.

I would expect I'd need to make some changes to the htaccess files - can anyone suggest how this would be done

So in a nutshell When I go to www.mysite.com - it looks at the /wp folder but still appears as www.mysite.com in the address bar.

解决方案

Adding these lines to .htaccess should do the job (not tested, sorry, it may not be sufficient):

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ wp [L]

Update: You might wish to check https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory for a way to accomplish this that's closer to WordPress standards.

这篇关于在子目录中运行Wordpress(而不是根目录)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆