链接在 Wordpress 4.1 中不起作用

Links not working in Wordpress 4.1

我在 DigitalOcean 上有 Wordpress 4.1 应用程序。

安装后我发现除了root/homelink之外的任何其他link都不起作用。

我研究了类似的问题并尝试过:

1) 将 permalinks 更改为默认设置。

现在 link 部分工作。我的意思是它们很丑 :http://104.131.95.146/?post_type=product 而不是 http://104.131.95.146/products

按照建议,我根据这个 link 进行了一些故障排除:

Pretty permalink可在以下位置找到: 具有 mod_rewrite 模块的 Apache Web 服务器

但我的服务器是 Apache,我检查了 mod_rewrite 是否可用:

apache2ctl -M | grep rewrite

收到此消息:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
 rewrite_module (shared)

尝试重新启动 apache 和我的 droplet,但问题仍然存在。

我的 htacces 文件在 var/www/html/.htaccess

# 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 安装的重要部分。

我做了什么:

默认情况下,这是 000-default.conf,但如果您创建了另一个配置文件,您的文件可能会有所不同:

sudo nano /etc/apache2/sites-available/000-default.conf

在这个文件中,我们要设置一些东西。我们应该设置 ServerName 并创建一个允许覆盖的目录部分。这应该看起来像这样:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ServerName server_domain_name_or_IP
    <Directory /var/www/html/>
        AllowOverride All
    </Directory>
    . . .

完成后,保存并关闭文件。

接下来,我们需要启用重写模块,它允许您修改 URL。您可以通过键入以下内容来执行此操作:

sudo a2enmod rewrite

完成这些更改后,重新启动 Apache:

sudo service apache2 restart