如何在Django子目录中安装WordPress?

时间:2023-01-12 18:37:50

I have Django set up on my server at http://stevencampbell.org/

我在我的服务器上安装了Django,网址是:http://stevencampbell.org/

I want to be able to run WordPress at stevencampbell.org/blog/

我希望能够在stevencampbell.org/blog/上运行WordPress

I'm running all my Python and Django files through Fast_CGI (only Django option on my server). My .htaccess file looks like this:

我通过Fast_CGI运行我的所有Python和Django文件(我的服务器上只有Django选项)。我的.htaccess文件如下所示:

AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteRule ^(/media.*)$ /$1 [QSA,PT]
RewriteRule ^(/adminmedia.*)$ /$1 [QSA, PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]

Assumedly, I need to add another RewriteRule in for the blog directory, but none of my attempts so far have worked. I can access /blog/index.php, but /blog/ gives me a Django error, meaning that the directory is still be processed by the dispatch.fcgi file.

假设我需要在博客目录中添加另一个RewriteRule,但到目前为止我没有尝试过。我可以访问/blog/index.php,但是/ blog /给了我一个Django错误,这意味着该目录仍然由dispatch.fcgi文件处理。

Also, I'm not really sure what I'm doing with these rewrite rules. Let me know if I'm doing anything else wrong.

另外,我不确定我正在做什么这些重写规则。如果我做错了什么,请告诉我。

2 个解决方案

#1


1  

AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteRule ^(/media.*)$ /$1 [QSA,PT]
RewriteRule ^(/adminmedia.*)$ /$1 [QSA, PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/blog(/.*)?$
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]

See that extra RewriteCond? Basically says "if the request is not /blog or /blog/whatever, then rewrite requests to dispatch.fcgi

看到额外的RewriteCond?基本上说“如果请求不是/ blog或/ blog / what,那么重写对dispatch.fcgi的请求

In your WordPress .htaccess inside /blog, you should add the line RewriteBase /blog/ right after the RewriteEngine On statement.

在你的WordPress .htaccess里面/博客中,你应该在RewriteEngine On语句之后添加RewriteBase / blog /行。

#2


0  

This sounds a little awkward. I don't know enough about mod_rewrite to get check your settings but why don't you simply use a Django based blogging engine instead of wordpress. Something like http://github.com/nathanborror/django-basic-apps perhaps?

这听起来有点尴尬。我不太了解mod_rewrite来检查你的设置,但为什么不简单地使用基于Django的博客引擎而不是wordpress。或许像http://github.com/nathanborror/django-basic-apps这样的东西?

#1


1  

AddHandler fastcgi-script .fcgi
RewriteEngine On
RewriteRule ^(/media.*)$ /$1 [QSA,PT]
RewriteRule ^(/adminmedia.*)$ /$1 [QSA, PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/blog(/.*)?$
RewriteRule ^(.*)$ dispatch.fcgi/$1 [QSA,L]

See that extra RewriteCond? Basically says "if the request is not /blog or /blog/whatever, then rewrite requests to dispatch.fcgi

看到额外的RewriteCond?基本上说“如果请求不是/ blog或/ blog / what,那么重写对dispatch.fcgi的请求

In your WordPress .htaccess inside /blog, you should add the line RewriteBase /blog/ right after the RewriteEngine On statement.

在你的WordPress .htaccess里面/博客中,你应该在RewriteEngine On语句之后添加RewriteBase / blog /行。

#2


0  

This sounds a little awkward. I don't know enough about mod_rewrite to get check your settings but why don't you simply use a Django based blogging engine instead of wordpress. Something like http://github.com/nathanborror/django-basic-apps perhaps?

这听起来有点尴尬。我不太了解mod_rewrite来检查你的设置,但为什么不简单地使用基于Django的博客引擎而不是wordpress。或许像http://github.com/nathanborror/django-basic-apps这样的东西?