简体   繁体   English

WordPress永久链接不起作用

[英]WordPress Permalinks Doesn't Work

I'm trying to create pretty permalinks through WordPress and I keep getting 404 errors. 我试图通过WordPress创建非常永久链接,我不断收到404错误。 I've scoured the internet and I can't find any solution. 我已经浏览了互联网,我找不到任何解决方案。 I've never had an issue with this before so I'm totally stumped. 我之前从来没有遇到过这样的问题,所以我完全难过了。

The hosting is under Network Solutions. 托管在网络解决方案下。 I called them and they sent me this link: http://www.networksolutions.com/support/PHP-ini-for-UNIX-Shared-Hosting-FAQ 我打电话给他们,他们给我发了这个链接: http//www.networksolutions.com/support/PHP-ini-for-UNIX-Shared-Hosting-FAQ

What I've tried: 1. Adding a php.ini file to my root. 我尝试过:1。将php.ini文件添加到我的root。 2. Adding a php.ini file to the cgi-bin folder 3. Adding the rewrite commands to my .htaccess file (which is located in the root of my website). 2.将php.ini文件添加到cgi-bin文件夹3.将重写命令添加到我的.htaccess文件(位于我的网站的根目录中)。

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

After each of these, I've resaved the permalink settings to flush the changes. 在完成其中的每一个之后,我重新保存了永久链接设置以刷新更改。

I still keep getting a 404 error. 我仍然收到404错误。

I had the same problem on an Ubuntu 14.04 server which is running as a staging server. 我在作为登台服务器运行的Ubuntu 14.04服务器上遇到了同样的问题。 In this case the rewrite module was not enabled by default; 在这种情况下,默认情况下未启用重写模块; so Pagination and "non-ugly" Permalinks were not working (as they rely on .htaccess rewrite rules to work). 因此,分页和“非丑陋”的永久链接不起作用(因为它们依赖.htaccess重写规则来工作)。

You have to edit the Apache conf file (in Ubuntu 14.04: /etc/apache2/apache2.conf) and change the AllowOverride setting from None to FileInfo 您必须编辑Apache conf文件(在Ubuntu 14.04中:/etc/apache2/apache2.conf)并将AllowOverride设置从None更改为FileInfo

<Directory /var/www/>
        Options Indexes FollowSymLinks 
        AllowOverride FileInfo
        Require all granted
</Directory>

You may need to enable the Rewrite module: 您可能需要启用重写模块:

sudo a2enmod rewrite

and to complete you will need to restart 并完成您将需要重新启动

sudo service apache2 restart

That's been bugging me for a month or so, now, so kudos to the solution found: https://askubuntu.com/questions/48362/how-to-enable-mod-rewrite-in-apache 现在,这已经困扰了我一个月左右,所以对解决方案的赞誉如下: https//askubuntu.com/questions/48362/how-to-enable-mod-rewrite-in-apache

Login to your server using FTP, and modify the .htaccess file which is located in the same location where folders like /wp-content/ and /wp-includes/ are located. 使用FTP登录您的服务器,并修改.htaccess文件,该文件位于/ wp-content /和/ wp-includes /所在文件夹所在的同一位置。 The easiest thing you can do is to temporarily make the file writeable by changing the permissions to 666. Then repeat the original solution. 您可以做的最简单的事情是通过将权限更改为666来临时使文件可写。然后重复原始解决方案。 Don't forget to change the permissions back to 660. You can also manually add this code in your .htaccess file: 不要忘记将权限更改回660.您也可以在.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

Another solution: Put index.php at the start of your custom permalink structure, for example: 另一种解决方案:将index.php放在自定义永久链接结构的开头,例如:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM