WordPress“帖子名称”永久链接不起作用

Sar*_*mer 5 wordpress .htaccess lamp permalinks ubuntu-server

我有一个在 Ubuntu Server 14.04 上的 Lamp Server 上运行的 WordPress 网站。我只是尝试使用永久链接选项Post Name,现在我的页面不再加载。

我打开mod_rewriteApache服务器的功能,重新启动,还是不行。

另外,这是我的.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
Run Code Online (Sandbox Code Playgroud)

请注意,文件夹的内容/wordpress已直接放入其中,/html 假设我的网站名称是mywebsite.com

我怎样才能让它发挥作用?

编辑:这是我的/etc/apache2/sites-available/000-default.conf文件

    <VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html


    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Run Code Online (Sandbox Code Playgroud)

小智 12

我找到了解决办法。很高兴!

\n\n

简而言之,我的解决方法是进入 WordPress 管理仪表板,转到:

\n\n

\xe2\x80\x9cSettings\xe2\x80\x9d > \xe2\x80\x9cPermalinks\xe2\x80\x9d > \xe2\x80\x9c通用设置\xe2\x80\x9d,并将单选按钮设置为 \xe2\x80 \x9c自定义结构\xe2\x80\x9d

\n\n

,然后粘贴到文本框中:

\n\n

/index.php/%year%/%monthnum%/%day%/%postname%/

\n\n

,然后单击“保存”按钮

\n

  • 奇怪的解决方案,但它的作用就像一个魅力。 (2认同)

小智 8

对于那些运行 apache 2.4 且未找到“默认”的用户,请查看 /etc/apache2/apache2.conf 并进行编辑

目录

允许覆盖全部

目录


目录 /var/www/>

允许覆盖全部

目录


小智 4

您是否启用了 .htaccess 的使用(如此处所述)? https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles