homepage Welcome to WebmasterWorld Guest from 54.227.160.102
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
freeflyer56

5+ Year Member



 
Msg#: 3561301 posted 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 ...

index.php?cName=

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 :)

 

Brett_Tabke

WebmasterWorld Administrator brett_tabke us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3561301 posted 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?

freeflyer56

5+ Year Member



 
Msg#: 3561301 posted 10:38 pm on Jan 29, 2008 (gmt 0)

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

so for example..

index.php?cName=extension-ladders
index.php?cName=loft-ladders
index.php?pName=3-section-ladder

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

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3561301 posted 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.

Jim

freeflyer56

5+ Year Member



 
Msg#: 3561301 posted 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.

freeflyer56

5+ Year Member



 
Msg#: 3561301 posted 11:08 am on Jan 30, 2008 (gmt 0)

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

domain.com/product_info.php?cPath=121&products_id=
domain.com/index.php?sort=3a&page=1&cName=

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

How do i amend the command to do that?

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3561301 posted 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.

Jim

freeflyer56

5+ Year Member



 
Msg#: 3561301 posted 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...

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3561301 posted 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... :)

Jim

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