[英].htaccess rewrite for Wordpress host hosted on Bitnami/EC2
我在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
等等
有人知道如何进行此更改吗?
在该文件中,您需要更改:
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_SITEURL
和WP_HOME
URL指向/blog
。
define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST'] . '/blog');
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST'] . '/blog');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.