Wordpress 404错误自定义重定向.htaccess

时间:2017-10-09 16:24:19

标签: wordpress .htaccess redirect http-status-code-404

我想在与Wordpress安装相同的域中添加一些自定义重定向。我想要这样的东西:

domain.com/get/card/123456 

转到:

domain.com/account/client/redirectNewCard.php?id=123456

我希望在其他2个重定向中使用相同的原则," client / validate / email /" en" enterprise / validate / email /"。但它们都不起作用。

Wordpress正在说404页面找不到" Page找不到"但访问" my domain.com/account/client/redirectNewCard.php?id=123456"能够工作并显示出应该出现的内容。

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^get/card/([0-9]+)$ /account/client/redirectNewCard.php?id=$1 [R]
RewriteRule ^client/validate/email/([0-9]+)$ /client/accountinstellingen.php?code=$1 [R]
RewriteRule ^enterprise/validate/email/([0-9]+)$ /enterprise/instellingen.php?code=$1 [R]

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

我已经尝试过重定向BEFORE以及Wordpress重定向之后,但这些方法都没有帮助。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">Navbar</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <div class="btn-group ml-auto">
        <button type="button" class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Welcome</button>
        <div class="dropdown-menu dropdown-menu-right">
            <button class="dropdown-item" type="button">Action</button>
            <button class="dropdown-item" type="button">Another action</button>
            <button class="dropdown-item" type="button">Something else here</button>
        </div>
    </div>
  </div>
</nav>

您需要在每个指令中包含RewriteRule ^get/card/([0-9]+)$ /account/client/redirectNewCard.php?id=$1 [R] RewriteRule ^client/validate/email/([0-9]+)$ /client/accountinstellingen.php?code=$1 [R] RewriteRule ^enterprise/validate/email/([0-9]+)$ /enterprise/instellingen.php?code=$1 [R] L)标志。即。 last

如果没有[R,L]标志,处理将继续,并且可能会被W​​ordPress前端控制器重写。您需要立即停止和重定向的处理。