How to Do 301 Redirect on This Case? Plz Help.

seowarrior008

Senior Member
Joined
Feb 7, 2012
Messages
930
Reaction score
248
Hi guys, I recently found my website home page got different URLs indexed. The home page indexed should be
mydomain.com

However, I also found there are different home page URLs that are also indexed in Google, like this

mydomain.com/page/1
mydoman.com/page/2
mydomain.com/page/3

I am not sure why and how these different versions of the home page are produced, but they are indeed indexed in G.
So, I wanna redirect all those page/1, page/2.... to my home page - mydomain.com
I used the plugin "Redirection" and set up this rule: /page/* to mydomain.com, but it fails to properly redirect.

So, do you guys know how to properly set up such redirection in bulk? or u have different ways to handle this problem?

thanks a lot in advance
 
Create ".htacces" file inside root site folder which contains:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
</IfModule>

Redirect 301 /page/1/ https://mydomain.com/
Redirect 301 /page/2/ https://mydomain.com/
Redirect 301 /page/3/ https://mydomain.com/

https://www.semrush.com/blog/301-redirect-htaccess/
thanks for reply, and yeah, I already thought that option,
but my problem is there are not only 3 pages but there might also be many other pages, like page/4, page/5....,

so how can i create a single rule to redirect all those pages to my home page?

Just no idea of how these pages were created.

thanks bro
 
You may try this:
Code:
RewriteRule ^/page/[0-9]+/$ https://mydomain.com/ [R,L]

Will be redirected these pages:
/page/1/
/page/2/
...
/page/100/
/page/101/
...
/page/1000/
etc
 
You may try this:
Code:
RewriteRule ^/page/[0-9]+/$ https://mydomain.com/ [R,L]
Code:
RewriteRule ^/page/(.*)$ https://mydomain.com/ [R=301,NC,L]
Hey guys, thanks so much for the code, and both codes are working great!

I tried htaccess first, but failed to do the redirection, then I changed it to the redirection plugin, it works.

thanks again.
 
Hi, do u guys know how to redirect these?

redirect:

mydomain.com/?_page=1
mydomain.com/?_page=2
mydomain.com/?_page=3
mydomain.com/?_page=4
.
.
to mydomain.com

cant figure out whats the proper codes to redirect these urls with "?" in there.

much appreciate if anyone can help.

thanks
 
Hi, do u guys know how to redirect these?

redirect:

mydomain.com/?_page=1
mydomain.com/?_page=2
mydomain.com/?_page=3
mydomain.com/?_page=4
.
.
to mydomain.com

cant figure out whats the proper codes to redirect these urls with "?" in there.

much appreciate if anyone can help.

thanks
Those are URL queries. Where do you want to redirect them?

You can try this:

Code:
    RewriteCond %{QUERY_STRING} key=value
    RewriteRule (.*) mydomain.com [R=301,L]
 
And please check your website. It looks like you've got yourself some digital herpes. :D
yeah, bro, i doubt if someone hacked my website.

I wanna redirect those URL queries to home page, mydomain.com
I inserted the codes block u gave me above, but looks like the redirection doesnt happen as i expected.

thanks bro
 
Try this:
Code:
RewriteCond %{QUERY_STRING} _page=[0-9]+
RewriteRule (.*) mydomain.com [R=301,L]
That's the one. I forgot to change key=value

Anyway i think his website is infected so he needs to clear it first or otherwise those links will continue to popup as soon as cron is triggered.
 
Try this:
Code:
RewriteCond %{QUERY_STRING} _page=[0-9]+
RewriteRule (.*) mydomain.com [R=301,L]
thanks bro, and try this code in htaccess, but it redirected from

mydomain.com/?_page=10
to
mydomain.com/mydomain.com?_page=10

if i enter other numbers, e,g ?_page=6, the same redirection happened.

Any idea of how to solve this? thanks bro
 
Code:
RewriteCond %{QUERY_STRING} _page=[0-9]+
RewriteCond %{REQUEST_URI} ^/page/?$
RewriteRule . / [R=301,L]
 
Code:
RewriteCond %{QUERY_STRING} _page=[0-9]+
RewriteCond %{REQUEST_URI} ^/page/?$
RewriteRule . / [R=301,L]
thanks bro, but this codes doesnt work either,

the only difference is this code return a "the page doesn't exist" error page, but the first code could not load up my website.

thanks
 
thanks bro, but this codes doesnt work either,

the only difference is this code return a "the page doesn't exist" error page, but the first code could not load up my website.

thanks

Have you cleared your browser cache? This can pose an issue. Also, my code can be buggy too (tbh I haven't payed with this for some time)
 
Yeah, I did clear everything, but it just cant redirect to the home page, but only display "This page does not exist" error on page.

The first block of codes by @Nevep returns "ERR_TOO_MANY_REDIRECTS" error.

thanks guys
 
I will check this tomorrow with clear head. Point is to setup several conditions and redirect them all to your homepage. @Nevep's solution was probably got caught in an infinite loop while mine had some broken redirect rule and/or condition. Regex is a bitch you shouldn't fuck with after you had a dinner and trying to watch a move :D
 
Apache .htaccess:
Redirect 301 /old-page.html http://www.mydomain.com/page/1

OR
  1. <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.mydomain.com/page/1");
    exit();
    ?>

Hi guys, I recently found my website home page got different URLs indexed. The home page indexed should be
mydomain.com

However, I also found there are different home page URLs that are also indexed in Google, like this

mydomain.com/page/1
mydoman.com/page/2
mydomain.com/page/3

I am not sure why and how these different versions of the home page are produced, but they are indeed indexed in G.
So, I wanna redirect all those page/1, page/2.... to my home page - mydomain.com
I used the plugin "Redirection" and set up this rule: /page/* to mydomain.com, but it fails to properly redirect.

So, do you guys know how to properly set up such redirection in bulk? or u have different ways to handle this problem?

thanks a lot in advance
 
Apache .htaccess:
Redirect 301 /old-page.html http://www.mydomain.com/page/1

OR
  1. <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://www.mydomain.com/page/1");
    exit();
    ?>
thanks bro, for helpful reply, and I solved this redirection yesterday.

however, i still have no idea of how to complete this redirection:

mydomain.com/?_page=1
mydomain.com/?_page=2
mydomain.com/?_page=3
.
.
Redirected these to the home page

mydomain.com

I tried some codes in htacces, but still no lucky to set up proper redirection by now.

Much appreciate if you can help set up this redirection.

thanks
 
Back
Top