homepage Welcome to WebmasterWorld Guest from 54.167.173.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Redirects with a wildcard
gjfortin




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

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

 

g1smd




msg:4554947
 10:17 pm on Mar 14, 2013 (gmt 0)

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.

lucy24




msg:4554956
 11:17 pm on Mar 14, 2013 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved