3

在我的 WordPress 3.5.2 站点的前端,我有三个按钮:主页、博客和示例页面。当我的永久链接设置设置为 时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 
4

2 回答 2

5

我通过谷歌搜索“永久链接 htaccess amazon ec2”发现了这一点,它可能会有所帮助: http: //guiem.info/permalinks-on-wordpress-amazon-ec2/

于 2013-07-21T01:52:38.120 回答
3

在 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 自动执行此操作,则使用 .将文件权限更改为 777 chmod

于 2013-10-10T17:40:47.820 回答