Forum Moderators: phranque

Message Too Old, No Replies

Forwarding multiple pages

Url

         

grin1dan

9:41 pm on Mar 2, 2010 (gmt 0)

10+ Year Member



Hello, I need to accomplish the following:
redirect the following urls to [tbp-dev.uhc.com...]
- [tbp-dev.uhc.com...]
- [tbp-dev.uhc.com...]
- [tbp-dev.uhc.com...]
- [tbp-dev.uhc.com...]

I have written the following code to accomplish this and need some ponters on whether it is correct.

RewriteEngine On
RewriteRule /.* [tbp-dev.uhc.com...] [R]

I am thinking that this is overkill and wondering how I can write regex for the 4 unique starting points.
Thanks.

grin1dan

10:24 pm on Mar 2, 2010 (gmt 0)

10+ Year Member



I am wondering if:
RewriteEngine On
RewriteRule /index.htm [tbp-dev.uhc.com...] [R]
RewriteRule /index.html [tbp-dev.uhc.com...] [R]
RewriteRule /portal/auth/portal/landing/home [tbp-dev.uhc.com...] [R]

is valid code?

grin1dan

11:05 pm on Mar 2, 2010 (gmt 0)

10+ Year Member



Ok...I am wondering if this will do the trick:

RewriteCond %{HTTP_HOST} (.*) [NC]
RewriteRule ^(/|/index\.(html|htm)|)$ /home [R]

Please advise. TIA.

g1smd

12:40 am on Mar 3, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It would be valid in httpd.conf, and produces a 302 redirect.

However, you probably want a 301 redirect here.

You'll also need to add the [L] flag to every rule.

If the rules are for .htaccess be aware that the RewriteRule cannot see the leading slash of the URL request.

You should also start and end anchor the patterns and make sure they only activate for direct client requests.

The redirect target should also include protocol and domain name, not just the path part of the URL.

It also matters whether the https and http URLs resolve to different folders on the server.

If they resolve to the same folder, you'll need additional canonicalisation code with extra RewriteCond lines testing SERVER_PORT values.

grin1dan

6:15 pm on Mar 3, 2010 (gmt 0)

10+ Year Member



Hi and thanks for the reply. Whay is the 301 redirect better in this situation? Thanks.

jdMorgan

8:40 pm on Mar 3, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A 301-Moved-Permanently response tells the search engines to index and list *only* the /home URL, whereas 302-Found does not, and can cause duplicate-content problems.

Jim

g1smd

8:42 pm on Mar 3, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Perhaps you might explain why you think the 302 is the best solution?

What's your thinking here?

grin1dan

9:23 pm on Mar 4, 2010 (gmt 0)

10+ Year Member



My thinking was just that the 302 is the most common, not really knowing much about redirection and ramifications between 301,302,303,307 and any others there might be. I am a complete novice to all this and I am hoping to get help from this forum.

g1smd

11:27 pm on Mar 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



A permanent redirect (301) is what you require.

It's a rare event that you'll need any other type.