0

我在 Amazon EC2 上安装了一个 Bitnami Ubuntu Wordpress 实例。

Bitnami 实例上的wordpress.conf文件就像一个 htaccess 文件。

目录结构如下:

/opt/bitnami/apps/wordpress/htdocs/index.php

wordpress.conf文件包含

Alias /wordpress/ "/opt/bitnami/apps/wordpress/htdocs/"
Alias /wordpress "/opt/bitnami/apps/wordpress/htdocs"

<Directory "/opt/bitnami/apps/wordpress/htdocs">
    Options Indexes MultiViews +FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
</Directory>

# Uncomment the following lines to see your application in the root
# of your URL. This is not compatible with more than one application.
#RewriteEngine On
#RewriteRule ^/$ /wordpress/ [PT]

这使得博客出现在这个 URL 上

http://ec2instance.com/wordpress/

我希望它是(包括查看单个帖子时):

http://ec2instance.com/blog/

http://ec2instance.com/blog/post-number-1

http://ec2instance.com/blog/post-number-2

ETC

有人知道如何进行此更改吗?

4

1 回答 1

3

在该文件中,您将需要更改:

Alias /wordpress/ "/opt/bitnami/apps/wordpress/htdocs/"
Alias /wordpress "/opt/bitnami/apps/wordpress/htdocs"

Alias /blog/ "/opt/bitnami/apps/wordpress/htdocs/"
Alias /blog "/opt/bitnami/apps/wordpress/htdocs"

随着这一变化,apache 将在/blog.

然后,您还需要在该文件中更改重写规则(因为新的 url 将使用/blog而不是/wordpress)。

RewriteBase /wordpress/
RewriteRule . /wordpress/index.php [L]

RewriteBase /blog/
RewriteRule . /blog/index.php [L]

最后,您还需要修改wp-config.php文件(in apps/wordpress/htdocs),确保WP_SITEURLWP_HOMEurl 指向/blog.

define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/blog');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/blog');
于 2012-04-20T11:29:20.200 回答