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

时间:2015-06-07 18:33:14

标签: wordpress .htaccess lamp permalinks ubuntu-server

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

我打开了Apache服务器的mod_rewrite功能,重启了它,但它仍然无效。

此外,这是我的.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文件夹的内容已直接放在/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

3 个答案:

答案 0 :(得分:3)

您是否已启用此处所述的.htaccess? https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles

答案 1 :(得分:1)

对于那些运行 apache 2.4 并且在 /etc/apache2/apache2.conf 中找不到“默认”并编辑的人

目录

允许覆盖所有

目录


目录/var/www/>

允许覆盖所有

目录

答案 2 :(得分:0)

我找到了解决方法。好开心!

简而言之,对我来说,解决方法是进入WordPress管理控制台,转到:

“设置”>“固定链接”>“通用设置”,并将单选按钮设置为“自定义结构”

,然后粘贴到文本框中:

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

,然后单击“保存”按钮