从Wordpress网址中删除index.php [英] Remove index.php from Wordpress URLs

查看:91
本文介绍了从Wordpress网址中删除index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Wordpress的新手,但尝试了所有文档和Stack Overflow帖子以寻求可能的解决方案,但是到目前为止,它们都没有起作用。

I am new to Wordpress but tried all documentation and Stack Overflow posts for possible solutions but none of them have worked so far.

我已确认mod rewrite是已启用并按预期工作。遵循此处提到的所有步骤。 https://wordpress.stackexchange.com/questions/105795/remove-index-php- from-permalinks

I have verified that mod rewrite is enabled and working as expected. Followed all steps mentioned here. https://wordpress.stackexchange.com/questions/105795/remove-index-php-from-permalinks

也重新启动了Apache几次,但是当我从Permalink设置中删除index.php路径时仍然出现404错误。

Also restarted Apache couple of times but still getting 404 errors when I remove index.php path from Permalink Settings.

将wordpress目录重命名为博客以访问该网站,网址为www.xyz.com/blog。现在的要求是访问所有带有
的博客帖子,网址为www.xyz.com/blog/2018/02/09/my-wp-post,URL中没有index.php。

Renamed the wordpress directory to blog to access the site at www.xyz.com/blog. Now the requirement is to access any blog posts with www.xyz.com/blog/2018/02/09/my-wp-post without index.php in the URLs.

除了博客网站的WP外,我们没有其他CMS内容。

We don't have any other CMS content other than WP for the blog site.

永久链接设置(自定义结构):
/ index.php /%year%/%monthnum%/%day%/%postname%/

Permalink settings(Custom Structure): /index.php/%year%/%monthnum%/%day%/%postname%/

.htaccess文件内容:

.htaccess file contents:

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

推荐答案

我花了很多时间尝试在这里或其他地方回答许多不同的方法,但是没有一个方法可以解决我的问题。

I spent ton of time trying many different approaches answered here or elsewhere but none of them fixed my issue.

这就是我所做的,并且已经解决了我的问题。

This is what I did and it has fixed my issue.


  1. 更改永久链接设置以删除index.php

  2. 更新/保存位于以下目录的.htaccess内容如果在我们更改WP管理面板中的永久链接设置时不允许自动更新WP安装。

  3. 这是重要的步骤,因为Q&除了wordpress文档以外,此处都对此进行了详细提及。专门检查AllowOverride设置并将其更改为All,如果没有此更改,Apache httpd.conf将不会加载.htaccess内容。当然,如果尚未完成,则必须在服务器中启用mod_rewrite。在我们的示例中,默认情况下启用了此功能,因此不必弄乱此步骤。

  4. 还要确保如WP文档中所述启用FollowSymLinks选项。

  5. 最后但并非最不重要的一点,请确保重新启动Apache服务/服务器以使更改生效。

  1. Change permalink settings to remove index.php
  2. Update/Save .htaccess content that's at the root of the WP installation if it's not allowed to be updated automatically when we change permalink settings in WP admin panel.
  3. This is the important step since not many Q & A mentioned this in detail, other than wordpress documentation here. Specifically check AllowOverride settings and change it to All, Apache httpd.conf will not load the .htaccess contents without this change. Of course mod_rewrite must be enabled in the server if it's not already done. In our case it's enabled by default, so didn't have to mess with this step.
  4. Also make sure FollowSymLinks option enabled as mentioned in the WP documentation.
  5. Last but not least, make sure you restart the Apache service/server for the changes to take effect.

httpd.conf文件:

Entry in httpd.conf file:

<Directory "/var/www/html/blog">
Options FollowSymLinks
AllowOverride All

这篇关于从Wordpress网址中删除index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆