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

Apache Web Server Forum

redirect permanent wildcard

 8:27 pm on Jan 29, 2008 (gmt 0)

hi all!

I need to redirect a bunch of dynamic url's created on an e-commerce site..

anything that starts with ...


needs to be permanetly redirected to the home page, but i cant figure out how to get the wildcard working. Obviously i dont want index.php redirected, otherwise it just goes in a loop.

This is for search engine reasons.. i'm ditching the index.php?cname system due to duplicates, and there are too many to remove manually. I'm thinking if i set up the redirect to the home page they'll eventually fizzle out.

Thanks for any help :)



 8:54 pm on Jan 29, 2008 (gmt 0)

Is the "?cName=" part static? YOu have to have something static that you can match on, or you will have to do it from within the index.php itself.

Whatelse is there in the dynamic url that you can match on?


 10:38 pm on Jan 29, 2008 (gmt 0)

yep the cName is always there, either that or pName..

so for example..


so the only thing that is constant in the url's is cName, pName or '=' , or occasionally an '&'.


 11:06 pm on Jan 29, 2008 (gmt 0)

I can't recommend that you redirect all these pages to your home page -- It'll look like you're trying to use lots of doorway pages. Here's how you can return a 410-Gone for those URLs:

RewriteCond %{QUERY_STRING} ^[cp]Name=
RewriteRule ^index\.php$ - [G]

If you insist on redirecting these pages, then you can use something like this:

RewriteCond %{QUERY_STRING} ^[cp]Name=
RewriteRule ^index\.php$ /index.php? [R=301,L]

You'd be far better off redirecting each dynamic page to its replacement -- at least the highest-ranked and highest-traffic ones.



 10:01 am on Jan 30, 2008 (gmt 0)

thanks Jim much appreciated.. i'll use the 'gone' code i thnk.

The only reason i'm not doing a straight redirect is because the pages carry no weight, arent ranked, and aren't landing pages. The index page collects 99% of traffic. There are alos a lot of dead links ('cant find product' pages) and duplicated pages, preventing good indexing of my current optimisied pages.

Given that there are about 1500 indexed pages, i think its better to ditch them , install the new system, and start again. Hopefully by the time th eold pages fizzle out the new ones (under different url's) will be indexed and working effectively.

Its a risk i know, but i dont have much choice.. i need to get my deeper pages in the serps, but the current mess is preventing it.


 11:08 am on Jan 30, 2008 (gmt 0)

ps sorry, i also need to do the same for anything with ...


ie 'product_info.php?cpath', and 'sort' in the url.

How do i amend the command to do that?


 3:43 pm on Jan 30, 2008 (gmt 0)

> ie 'product_info.php?cpath', and 'sort' in the url.

On which URL? index.php? product_info.php? Both?

You need well-defined requirements (a comprehensive list of URLs and attached query strings) before coding.



 7:55 pm on Jan 30, 2008 (gmt 0)

sorry, the pages i need to remove are all variants of the following...

domain.com/product_info.php?****** - remove ALL of the product_info.php pages, or if not possible anything that contains 'cPath' after the '?' .

domain.com/index.php?******** - remove anything that contains either 'cName' , 'pName' or 'sort' after the '?'

Thanks for any help..hope it makes sense...


 5:28 am on Feb 1, 2008 (gmt 0)

RewriteRule ^product_info\.php$ - [G]
RewriteCond %{QUERY_STRING} ^[cp]Name= [OR]
RewriteCond %{QUERY_STRING} ^sort=
RewriteRule ^index\.php$ - [G]

Dig into the documentation [httpd.apache.org] a bit; This isn't hard, and reading-up beats waiting around for people here to remember to check this thread... :)


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