【问题标题】:Wordpress .htaccess file dont work with apach2Wordpress .htaccess 文件不适用于 apache2
【发布时间】:2017-03-08 06:14:59
【问题描述】:

我不知道这应该在这里还是在 askubunt 中。

我认为我的问题在于 wordpress 永久链接。我可以访问首页,但没有图像,当我尝试访问任何链接时。我收到 404 错误。

但似乎 apache2 无法真正读取我的 wordpress .htaccess 文件。看起来像:

# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0
# End Error

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

我已经对我所有的 wordpress 文件授予了正确的权限,如下所示:

设置 .htaccess 644 的权限。将所有目录的权限设置为 755:find . -type d -print -exec chmod 755 {} \; 将所有文件的权限设置为 644:find . -type f -print -exec chmod 644 {} \;

我首先认为是我的 apache2 配置文件或 mysite.com.conf 文件有问题,但它们似乎是正确的。看起来像:

myste.com.conf

<VirtualHost *:80>    
    ServerAdmin webmaster@localhost
    DocumentRoot /home/mysite
    ServerName mysite.com
    ServerAlias www.mysite.com
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory "/home/mysite">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>


apache2 conf file (relevant)

<Directory /home/mysite>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

所以看起来一切都应该井井有条。

此外,当我尝试启用重写 a2enmod rewrite 时,我在尝试访问站点时收到 500 服务器错误。

可能是什么问题?我发现这样的所有问题是他们要么没有AllowOverride All,要么就是wordpress .htaccess 文件是错误的。但这似乎并非如此。

我该怎么办?

【问题讨论】:

  • 当 '500' 错误发生时,Apache 的错误日志会说什么?应该启用rewrite 模块以使重写工作,但其他一些重写规则可能会导致重定向循环。(特别是如果有多个 .htaccess 文件,或者上面的 .htaccess 文件中有其他重写规则此处未显示。)
  • @Matt 好的,奇怪。我现在做了sudo a2enmod rewrite,现在我没有得到错误。该网站仍然是相同的(不工作),但我没有收到错误。是的,我确实在 :) 之后重新启动了 apache

标签: wordpress apache .htaccess


【解决方案1】:

您的 .htaccess 文件有错误

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
....

【讨论】:

    猜你喜欢
    • 2010-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-08
    • 2012-11-08
    • 2021-02-23
    • 1970-01-01
    相关资源
    最近更新 更多