【问题标题】:Permalink configuration in wordpress and how to?wordpress 中的永久链接配置以及如何配置?
【发布时间】:2018-06-19 06:44:50
【问题描述】:

美好的一天。我在本地虚拟主机上运行我的网站,其网址如下所示:

1. Home page : www.vhost1.com/
2. Category Page (List of news) : www.vhost1.com/index.php/category/business
3. Article page (news detail) : www.vhost1.com/index.php/featured-article-4

我想将这些永久链接(隐藏 index.php)更改为

a. Category Page (List of news) : www.vhost1.com/category/business
b. Article page (news detail) : www.vhost1.com/categorty/business/featured-article-4

我尝试在 wp-admin 面板上设置永久链接,但是当我点击任何类别列表或文章时,网站显示“找不到对象”。 我必须在永久链接之间添加“index.php”,以便它可以重定向。 有什么办法可以解决这个问题?

【问题讨论】:

    标签: php wordpress url permalinks


    【解决方案1】:

    要从您的 Wordpress URL 中删除 index.php,您需要做两件事。

    第一步是更新 Wordpress 仪表板中的永久链接。

    登录到您的 Wordpress 仪表板,然后点击 设置 > 固定链接。在 Common Settings 下,选择 Custom Structure 并在文本字段中输入 /%postname%/

    点击保存更改

    第二步是创建一个 .htaccess 文件,然后将其上传到 Wordpress 站点的根目录。

    .htaccess 文件将包含以下规则:

    RewriteEngine on 
    RewriteBase / 
    
    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]
    
    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    

    【讨论】:

      猜你喜欢
      • 2017-04-06
      • 1970-01-01
      • 1970-01-01
      • 2016-01-16
      • 2018-04-01
      • 2019-02-13
      • 2017-05-06
      • 2011-01-24
      • 2011-09-22
      相关资源
      最近更新 更多