【问题标题】:wordpress custom Rewrite rule in htaccesshtaccess中的wordpress自定义重写规则
【发布时间】:2018-10-08 23:16:32
【问题描述】:

在我的 options-permalink.php 中,我有一个自定义结构,例如 http://myexamplesite.com/%category%/%postname%.html

我的 .htaccess:

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

</IfModule>

所以问题是:我需要在一些指定的帖子之前使用 RewriteRule。例如,如果我在浏览器中输入 http://myexamplesite.com/spec1.html 我必须查看 url http://myexamplesite.com/category1/mycustompost.html 没有重定向到这个页面。

为什么我的 RewriteRule 显示 404 错误?

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

RewriteRule ^spec1.html /category1/mycustompost.html [L,QSA]
RewriteRule ^spec2.html /category2/mycustompost2.html [L,QSA]

</IfModule>

感谢您的回答!

【问题讨论】:

    标签: wordpress mod-rewrite


    【解决方案1】:

    你可以试试这个语法。

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    RewriteRule ^spec1.html /category1/mycustompost.html [L,QSA]
    RewriteRule ^spec2.html /category2/mycustompost2.html [L,QSA]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-22
      • 1970-01-01
      • 2011-03-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多