首页 文章

Wordpress永久链接结构改变问题

提问于
浏览
7

我已经看到关于这个问题的其他一些帖子,但是没有一个建议的解决方案对我有用,所以我重新发布 .

将我的永久链接结构更改为 /%postname%/ 后,没有任何链接正常工作 . 我得到以下404:

Not Found

The requested URL /my-post-name/ was not found on this server.

Apache/2.2.20 (Ubuntu) Server at mysite.com Port 80

当我回到 default 永久链接结构时,它会再次开始工作,但我还是希望有 /%postname%/ 结构 .

我的 .htaccess 文件的 chmod 是777 .

将我的永久链接结构更新为 /%postname%/ 后,Wordpress生成的 .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

有什么想法吗?

编辑:

我试图将永久链接结构更改为以下内容:

/index.php/%postname%/

它很愉快地工作 . 但是,问题现在,毫不奇怪,链接的形式如下:

www.mysite.com/index.php/my-page.com

我的问题是如何从链接中删除 index.php . 当我从永久链接结构中删除它(即 /%postname%/ )时,我的链接不再起作用 .

PS:我没有使用博客条目,而只使用我网站中的网页 . 如果有必要,我的网站是:mll.sehir.edu.tr .

5 回答

  • 4

    听起来像服务器上的符号链接问题 . 在你的.htaccess中尝试这个,并且在进行更改后请将其更改为644:

    Options +FollowSymlinks
    RewriteEngine on
    
    # 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
    
  • 0

    如果您知道问题的根源,有多种方法可以解决此问题 .

    问题1

    首先,您的apache没有安装或启用mod_rewrite.c模块可能会出现问题 .

    因此,您必须按如下方式启用它

    打开你的控制台并输入它,这个:

    sudo a2enmod rewrite
    

    重启你的apache服务器 .

    service apache2 restart
    

    问题2

    除了上述内容之外,如果它不起作用,您还可以从apache conf文件( apache2.confhttp.conf000-default 文件)更改覆盖规则 .

    找到 Directory /var/www/

    Override None 更改为 Override All

    问题3

    如果您收到错误,指出未找到重写模块,那么可能您的userdir模块未启用 . 因此,您需要启用它 .

    在控制台中输入以下内容:

    sudo a2enmod userdir
    

    然后尝试启用重写模块,如果仍未启用(如上所述) .

    要进一步阅读此内容,您可以访问此站点:http://seventhsoulmountain.blogspot.com/2014/02/wordpress-permalink-ubuntu-problem-solutions.html

  • 1

    我有同样的问题,但我正在使用其他网址结构/%category%/%postname%/

    de 404错误的问题是因为即使你设置了某个结构,wordpress总是试图在url上创建带有“category”一词的url .

    尝试输入这样的网址:yoursite.com/category/postname,如果您现在没有收到任何错误,是因为我们即将解决错误 . 现在尝试安装此wordpress插件http://wordpress.org/extend/plugins/no-category-base-wpml/以从URL中删除"category" base

    让我知道你的进展

  • 0

    替换并尝试使用此.htaccess:

    选项FollowSymlinks

    RewriteEngine On

    RewriteCond% ^ hostname.com $

    RewriteRule ^( . *)$ http://www.hostname.com/$1 [R =永久,L]

  • 12

    每当我尝试启用我的网站永久链接到mod_rewrite时,我就遇到了这个问题:“Pretty Permalinks” . 我的站点是AWS EC2上的一个实例 .

    404 Errors 
    
    Page Not Found
    The requested URL .... was not found on this server.
    Apache/2.4.7 (Ubuntu) Server at mydomain.com Port 80
    

    我尝试了以上所有方法,但没有修复 .

    最后,我检查了/etc/apache2/sites-available/wordpress.conf,我发现我使用AWS分配给每个实例的公共IP地址 . 一旦我将其更改为当前的mydomain.com,它就可以了 .

    有时,wordpress.conf会被httpd(web serser)锁定,我们需要在编辑后停止并启动它 . 我们还需要使用:sudo service apache2 stop / start,以便wordpress.conf可以重新加载 .

    希望我的经历可以帮助别人 .

相关问题