除主页外,在此服务器上找不到请求的 URL (AWS EC2 wordpress)

Except homepage, the requested URL was not found on this server (AWS EC2 wordpress)

我在 AWS EC2 上托管两个 wordpress(比如 site1site2)。 site1完美,但是site2只能访问首页,其他页面,遇到如下错误:

Not Found

The requested URL /just-for-test/ was not found on this server.


Apache/2.4.7 (Ubuntu) Server at site2.com Port 80

两个站点都具有相同的权限。 site2配置文件/etc/apache2/sites-available/site2.conf如下:

<VirtualHost *:80>
    ServerAdmin admin@site2.com
    ServerName site2.com
    ServerAlias www.site2.com
    DocumentRoot /var/www/site2.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

/etc/hosts内容如下:

127.0.0.1 localhost  #this is for site1.com, 000-default.conf

xx.xx.xx.xx site2.com

顺便说一句,在访问http://site2.com/wp-content/uploads/时,一切正常。

Index of /wp-content/uploads

Name Last modified Size Description

Parent Directory -

2015/ 2015-05-24 00:17 -

Apache/2.4.7 (Ubuntu) Server at site2.com Port 80

如何解决?

检查每个站点上的 htaccess 文件并检查 mod_rewrite 是否为两个站点正确配置。

在@Giles Hunt 和@kittykittybangbang 的帮助下,我添加.htaccess到我的网站,内容如下:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

现在可以使用了。