skip to Main Content

I’m trying to do a 301 redirect using .htaccess file to redirect:

Target URL:
https://blanee.com/punaises-de-lit/punaises-de-lit-peau-de-mue/bpage/2000/

and after Redirection the URL :
https://blanee.com/punaises-de-lit/punaises-de-lit-peau-de-mue

I want to remove /bpage/2000/ that string from the URL.

NOTE: /2000/ this is an integer number, 1-2000 or more than more numbers in the URL, this random number, That I want to fetch.

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteCond %{QUERY_STRING} ^/bpage/([a-zA-Z])$
RewriteRule ^index.php$ /knowledgebase/ [L,R=301]
 
</IfModule>
# END WordPress

I have that code already uses in my WordPress

2

Answers


  1. Chosen as BEST ANSWER
    RewriteRule ^(.*)/bpage/d+/?$ /$1 [L,R=301]
    

    This is worked for me. Put this at the top of your .htaccess just below the line that says RewriteEngine on .


  2. You can use this in your htaccess :

    RewriteRule ^(punaises-de-lit/punaises-de-lit-peau-de-mue)/bpage/d+/?$ /$1 [L,R=301]
    

    Put this at the top of your htaccess just below the line that says RewriteEngine on .

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search