的.htaccess改写为托管在汇出/ EC2字preSS主机 [英] .htaccess rewrite for Wordpress host hosted on Bitnami/EC2

查看:151
本文介绍了的.htaccess改写为托管在汇出/ EC2字preSS主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Amazon EC2上安装了Ubuntu的汇出字preSS实例。

I installed a Bitnami Ubuntu Wordpress instance on Amazon EC2.

字press.conf 在汇出实例文件的行为像一个htaccess文件。

The wordpress.conf file on a Bitnami instance acts like an htaccess file.

的目录结构是如下所示:

The directory structure is as follows:

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

字press.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]

这使得博客出现这个网址

This makes the blog appear with this URL

http://ec2instance.com/word$p$pss/

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

I would like it to be (including when viewing individual posts):

http://ec2instance.com/blog/

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

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

任何人都知道如何使这种变化?

Anyone know how to make this change?

推荐答案

在该文件中,你需要改变:

In that file you will need to change:

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将服务于字preSS在 /博客

With that change apache will serve wordpress in /blog.

然后,你还需要修改重写规则在该文件中(因为新的URL会使用,而不是 /字$ P $ /博客 PSS )。

Then you need to change the rewrite rules also in that file (because the new urls will use /blog instead of /wordpress).

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

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

最后,您将还需要修改的wp-config.php文件文件(在应用程序/字preSS / htdocs目录)确保了 WP_SITEURL WP_HOME 网​​址指向 /博客

Finally you will need to modify also the wp-config.php file (in apps/wordpress/htdocs) making sure that the WP_SITEURL and WP_HOME urls points to /blog.

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

这篇关于的.htaccess改写为托管在汇出/ EC2字preSS主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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