php 更改永久链接 wordpress 后出现 404 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17206524/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:29:16  来源:igfitidea点击:

404 error after changing permalinks wordpress

phpwordpress

提问by Sagardevd

My site is a Wordpress-sitecreated with PHP.

我的网站是Wordpress-sitePHP.

I have made changes in permalink default to postname. It works fine in Chromeand Firefoxbut not in IE8. The front page displays correctly but when I click a link to another page, it shows a 404 page not found error.

我已将固定链接默认更改为 postname。它在 IE8 中运行良好ChromeFirefox但在 IE8 中不起作用。首页显示正确,但是当我单击指向另一个页面的链接时,它显示 404 页面未找到错误。

I'm using Wordpress version 3+.

我正在使用 Wordpress 版本 3+。

.htaccess file is

.htaccess 文件是

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

where WordPress is folder name. also in apache rewrite_module is enable

其中 WordPress 是文件夹名称。也在 apache rewrite_module 中启用

回答by Winchester

First put a .htaccessfile in your /var/www/folder and make it writable. Second, suppose your wordpress blog is in /var/www/blogfolder then go to /etc/apache2/sites-available/and make following changes in default file

首先将一个.htaccess文件放入您的/var/www/文件夹中并使其可写。其次,假设您的 wordpress 博客在/var/www/blog文件夹中,然后转到/etc/apache2/sites-available/并在默认文件中进行以下更改

<Directory /var/www/>
    Options +ExecCGI 
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
</Directory>
<Directory /var/www/blog/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
</Directory>

Now restart apache to make sure changes have taken effect. Hope it helps.

现在重新启动 apache 以确保更改已生效。希望能帮助到你。

回答by Gianfranco P.

After trying all of these answers and the instructions on codex.wordpress.org, I needed to enable mod_rewriteon Apache: https://stackoverflow.com/a/5758551/728287

在尝试了所有这些答案和 codex.wordpress.org 上的说明后,我需要mod_rewrite在 Apache上启用:https: //stackoverflow.com/a/5758551/728287

回答by Marc Steven Plotz

Just go into wordpress /wp-admin, which will still work, and navigate to settings->permalinks. When you go to that page, wordpress will rebuild your .htaccess file and everything will work again.

只需进入 wordpress /wp-admin,它仍然可以工作,然后导航到设置->永久链接。当您转到该页面时,wordpress 将重建您的 .htaccess 文件,一切都会再次运行。

EDIT (FROM http://codex.wordpress.org/Using_Permalinks)

编辑(来自http://codex.wordpress.org/Using_Permalinks

If the above does not work:

如果上述方法不起作用:

Paged Navigation Doesn't Work

分页导航不起作用

Sometimes navigation to second (and subsequent) pages of posts does not work as expected.

有时导航到帖子的第二页(和后续页)无法按预期工作。

The result of clicking one of those links is that the page loads with all the surroundings (header, footer, sidebar), but instead of a page of posts, there is an error message: "Sorry, no posts match that criteria."

单击其中一个链接的结果是页面加载了所有环境(页眉、页脚、侧边栏),但不是一页帖子,而是一条错误消息:“抱歉,没有帖子符合该条件。”

This is due to a glitch in the .htaccess file that WordPress generates. To fix it, delete the contents of your .htaccess file and re-create it.

这是由于 WordPress 生成的 .htaccess 文件中的一个小故障。要修复它,请删除 .htaccess 文件的内容并重新创建它。

In the Control Panel, go to Manage > Files (More Info on Editing Files)

在控制面板中,转至管理 > 文件(有关编辑文件的更多信息)

Click the link to your .htaccess file to edit its contents

单击指向您的 .htaccess 文件的链接以编辑其内容

Copy the contents of the file and paste it to a text file in a text editor. This is a precaution in case your .htaccess file has manual entries for redirects, denials or other handy htaccess tricks

复制文件的内容并将其粘贴到文本编辑器中的文本文件中。这是一个预防措施,以防您的 .htaccess 文件有重定向、拒绝或其他方便的 htaccess 技巧的手动条目

Delete all contents from your .htaccess file and click the Update File button.

从 .htaccess 文件中删除所有内容,然后单击“更新文件”按钮。

In the Control Panel, go to Options > Permalinks.

在控制面板中,转到选项 > 固定链接。

Click the Update Permalink Structure button to freshly generate new rewrite rules for your permalinks.

单击更新永久链接结构按钮为您的永久链接重新生成新的重写规则。

Test the results using a link that had previously broken.

使用先前断开的链接测试结果。

Add any manual htaccess entries back in your file (Place manual htaccess entries before the #BEGIN WordPress or after # END WordPress lines.)

在您的文件中添加任何手动 htaccess 条目(将手动 htaccess 条目放在#BEGIN WordPress之前或 # END WordPress 行之后。)

You may also perform similar steps by deleting the .htaccess files from the server, creating a fresh empty .htaccess file, changing its permissions to 666, and then in Options -> Permalinks generate a new set of htaccess rules by clicking the Update Permalinks Structure button.

您也可以通过从服务器删除 .htaccess 文件,创建一个新的空 .htaccess 文件,将其权限更改为 666,然后在选项 -> 永久链接中通过单击更新永久链接结构生成一组新的 htaccess 规则来执行类似的步骤按钮。

If that still doesn't work, take a look at the WordPress support forums, specifically http://wordpress.org/support/topic/permalink-nextpage-doesnt-work#post-283222

如果这仍然不起作用,请查看 WordPress 支持论坛,特别是http://wordpress.org/support/topic/permalink-nextpage-doesnt-work#post-283222

回答by Roland Muresan

I had the same issue locally, I tried everything above. After a while I realised how the vhost is setup for the application the .htaccess is not enabled.

我在本地遇到了同样的问题,我尝试了上面的所有方法。一段时间后,我意识到如何为应用程序设置 vhost 未启用 .htaccess。

<Directory "/Applications/XAMPP/htdocs/wordpress">
    Options FollowSymLinks
    AllowOverride All

    Order allow,deny
    Allow from all
</Directory>

Adding these lines, helped me a lot and resolved my issue.

添加这些行,对我有很大帮助并解决了我的问题。

回答by user3388353

Enable rewrite_modulein Apache-> Apache Moduels

rewrite_module在 Apache-> Apache 模块中启用