|
WordPress更改固定连接(permalinks)后只能访问首页问题处理
2021年09月03日 |
|
今天整理了一下网站,想将固定链接调整一下,但是又出现了只能访问首页,其他子页面提示无法访问的问题,联想到之前也出现过同样的问题,然后这次就研究了一下。 ![]() 看到了wordpress官网关于固定链接的介绍,发现需要开启apache的mod_rewrite module才能正常使用Pretty permalinks, 以下是原文: mod_rewrite: “Pretty Permalinks” #mod_rewrite: “Pretty Permalinks”Using mod_rewrite or lighttpd you can produce much nicer permalinks (see Pretty Permalinks). There are many different formats, but the most common, and most versatile looks like http://example.com/2012/post-name/ or http://example.com/2012/12/30/post-name Pretty permalinks are available under:
随后找了一下开启的方法,在这里找到了 如果不想打开链接的话,直接往下看即可。 我直接把对应的部分拷贝了出来,如果想看中文的话可以拉到最后 Enable Mod_rewrite ModuleThe
sudo nano /etc/httpd/conf.modules.d/00-base.conf
Add or uncomment the following line:
LoadModule rewrite_module modules/mod_rewrite.so
Save and close the file, then restart the
sudo systemctl restart httpd
Enable .Htaccess FileOnce the You can do this by editing
sudo nano /etc/httpd/conf/httpd.conf
Find the section
<Directory /var/www/html>
AllowOverride All
</Directory>
Save and exit. Now restart Apache to put the change into effect:
sudo systemctl restart httpd
第一步大概意思就是修改/etc/httpd/conf.modules.d/00-base.conf文件,将 LoadModule rewrite_module modules/mod_rewrite.so 这一句前的注释取消,如果没有这一句的话直接加上即可 我看了一下,我的是这个文件里的这部分是正常的,就没有调整。 然后我按照第二步调整了一下,网站显示就正常了,下面是调整步骤 修改/etc/httpd/conf/httpd.conf文件,找到如下类型的文本,修改为
<Directory /var/www/html>
AllowOverride All
</Directory>
修改完以后重启apache即可 sudo systemctl restart httpd 文本修改的方法可以参考我的关于vim配置的文章 此处理方案仅是个人环境的处理方案,仅供参考,有问题的话也可以留言讨论 |