在我的WordPress 3.5.2网站的前端,我有三个按钮:Home,Blog和Sample Page。当我的永久链接设置设置为Default
时,我可以访问这三个页面:
Home: http://ec2-xx-xxx-x-xxx.compute-1.amazonaws.com/
Blog: http://ec2-xx-xxx-x-xxx.compute-1.amazonaws.com/?page_id=13
Sample Page:
http://ec2-xx-xxx-x-xxx.compute-1.amazonaws.com/?page_id=2
但是,当我将永久链接设置更改为Post name
并刷新浏览器时,我无法访问“博客”页面和“样本”页面。我收到以下错误:
Blog: http://ec2-xx-xxx-x-xxx.compute-1.amazonaws.com/blog
Not Found
The requested URL /blog/ was not found on this server.
Sample Page:
http://ec2-xx-xxx-x-xxx.compute-1.amazonaws.com/sample-page/
Not Found
The requested URL /sample-page/ was not found on this server.
在WordPress的Settings -> Permalink Settings
中,我也收到了这条消息:
If your .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all.
当我检查.htaccess文件的权限时,我得到644,所以我将其更改为666并且消息消失了(我将其更改回644)
[ec2-user@ip-xx-xxx-xxx-xx html]$ ls -l .htaccess
-rw-r--r-- 1 root root 258 Jul 25 21:49 .htaccess
[ec2-user@ip-xx-xxx-xxx-xx html]$ sudo chmod 666 .htaccess
将永久链接设置更改为Post name
后,我仍然可以访问我的主页。我不确定这是否与我的问题有关,但我将我的WordPress网站安装在我的Amazon EC2微型实例的子目录(xxx)中,我更改了WP的常规设置,如下所示:
WordPress Address (URL): http://ec2-xx-xxx-x-xxx.compute-1.amazonaws.com/xxx
Site Address (URL): http://ec2-xx-xxx-x-xxx.compute-1.amazonaws.com
答案 0 :(得分:5)
我通过谷歌搜索“permalinks htaccess amazon ec2”发现了这一点,它可能会有所帮助:http://guiem.info/permalinks-on-wordpress-amazon-ec2/
答案 1 :(得分:2)
在Wordpress安装的根目录下创建一个.htaccess文件。然后添加以下内容 -
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
如果您希望Wordpress自动执行此操作,请使用chmod
将文件权限更改为777。