Forum Moderators: phranque

Message Too Old, No Replies

Redirect from large set of dynamic pages to single subdomain

How to avoid retaining everything after the?

         

geckofuel

5:42 pm on Feb 19, 2007 (gmt 0)

10+ Year Member



I have a lot of indexed pages that have this structure:

[domain.com...]

I'd like all of these pages to redirect to a single page at:

[subdir.domain.com...]

However, the rewrite rule that I'm currently using adds the "?id=2895" to the new URL so that I end up with:

[subdir.domain.com...] (I don't want this)

Here's the RewriteRule I'm using

RewriteRule ^file.* [subdir.domain.com...] [R]

For every page with the above structure, I simply want a redirect to the single subdomain page with no dynamic content attached.

Any suggestions?

jdMorgan

6:36 pm on Feb 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add a question mark to the end of the substitution URL, as described in the mod_rewrite documentation.

I'd also suggest that you redirect to appropriate replacement pages, rather than the single home page, and use a 301-Moved Permanently redirect to do so; Otherwise this exercise may be seen as an attempt to promote your site by using the same URL to access duplicate content... Search WebmasterWorld for "duplicate content" for more information about the trouble this can cause.

If an appropriate replacement page is not available, then returning a custom 410-Gone page with a brief and friendly explanation and a link to your site map, home page, and/or product category page is a better practice.

Jim

geckofuel

7:27 pm on Feb 19, 2007 (gmt 0)

10+ Year Member



For those of you who might use this post as a resource, I've taken jdMorgan's advice. Here's what I did. It works. I'm not sure if it's the most elegant solution:

Changes made to .htaccess

**************************
ErrorDocument 410 /gone.html
RewriteRule ^file.* [domain.com...] [G]
**************************

(I don't think the? is necessary, but I had already put it in and it worked.)

In case you didn't know the [G] indicates that this is a 410 - Gone error (permanent) and the "ErrorDocument 410 /gone.html" just specifies a custom 410 error document.

Custom error document created and uploaded to current home directory:
**************************
gone.html
**************************

jdMorgan

9:11 pm on Feb 19, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use just:

ErrorDocument 410 /gone.html
RewriteRule ^file - [G]

to equally-good effect.

Jim