Welcome to WebmasterWorld Guest from 174.129.135.89

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Redirects with a wildcard

   
9:04 pm on Mar 14, 2013 (gmt 0)

10+ Year Member



Hi,

I am not a mod rewrite expert. I am able to do simple redirects with htaccess using Cpanel. But I need to solve a specific problem:

I already made some redirects from my old website mysite.com such as:

RewriteRule ^folder\/oldpage\.html$ "http\:\/\/mysite\.com\/new\-page\/" [R=301,L

My new website is running on Wordpress

A lot of spammmy links where made from elsewhere when my old website was made in static html but these links where pointing to non existing php pages like this:
page.php?p=3787668&f=44
page.php?p=3789797&f=75


I have more than a thousand of these 404 in Google Webmaster tools and I would like to redirect all of them on one dedicated page to them on my new site to get rid of this important amount of 404. I know that it is better to use a wildcard for this but I do not know how to.

I want to redirect all these pages to [mynewsite...]

Could you tell me how to write this string of coding?

I also do not want to redirect urls from Wordpress.

Thank you
10:17 pm on Mar 14, 2013 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Look at the cPanel code then never do anything that looks like that ever again. :) It produces some of the worst code on the planet.

You'll need a RewriteCond to look at the requested query string and a RewriteRule looking at the requested path. There's many previous threads with example code as it's a question that comes up several times per week.

In the rule target NOTHING needs to be escaped and the quotes should be removed.

Use example.com in this forum to supress the auto-linking function.
11:17 pm on Mar 14, 2013 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



A lot of spammmy links where made from elsewhere when my old website was made in static html but these links where pointing to non existing php pages
<snip>
I have more than a thousand of these 404 in Google Webmaster tools and I would like to redirect all of them on one dedicated page to them on my new site to get rid of this important amount of 404.

No, you wouldn't. If unwanted external links to nonexistent pages are getting 404 responses, the correct thing is already happening.

ONLY redirect links that you want to keep, and then only if the link points to a specific page whose URL has now changed.

For all others, a well designed 404 page is all you need.