【问题标题】:.htaccess rewrite for Wordpress host hosted on Bitnami/EC2.htaccess 重写托管在 Bitnami/EC2 上的 Wordpress 主机
【发布时间】:2013-08-07 18:50:58
【问题描述】:

我在 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

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

【问题讨论】:

    标签: php wordpress .htaccess ubuntu


    【解决方案1】:

    您需要在该文件中进行更改:

    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 中提供 wordpress。

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

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

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

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

    define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/blog');
    define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/blog');
    

    【讨论】:

      猜你喜欢
      • 2011-10-07
      • 1970-01-01
      • 1970-01-01
      • 2018-03-23
      • 2016-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-03
      相关资源
      最近更新 更多