Forum Moderators: phranque

Message Too Old, No Replies

redirect from www.name.domain.com to www.domain.com/dir/name.htm

problem with mode_rewrite

         

nicco

10:26 am on Oct 3, 2005 (gmt 0)

10+ Year Member



i have to made several redirect from www.name.domain.com to www.domain.com/dir/name.htm using modrewrite but from htaccess the redirect works but explicit (address change). I need to make the rewite invisible. How to?

jdMorgan

4:11 am on Oct 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please post you code so we can discuss it.

Jim

nicco

6:44 am on Oct 4, 2005 (gmt 0)

10+ Year Member



sorry, this is the piece of code used:

RewriteCond %{HTTP_HOST}!^(www\.example)
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com
RewriteBase /
RewriteRule /$¦^$ http://www.example.com/reservation/%1-index.html

[edited by: jdMorgan at 8:06 pm (utc) on Oct. 4, 2005]
[edit reason] Example.com [/edit]

jdMorgan

2:33 pm on Oct 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Using a canonical substitution URL forces an external redirect. Instead, use a local URL-path to do an internal rewrite:

RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.example\.com
RewriteRule /$¦^$ /reservation/%1-index.html [L]

The first RewriteCond appeared to be redundant, in that "www.example.com" won't match "www.<something>.example.com", so I removed it in the interest of efficiency. Also, always use an [L] flag unless you know you don't want to. The [L] flag will prevent the rewrite engine from continuing to process subsequent rules after mathing and applying the current rule.

Jim

[added] Replace the broken pipe "¦" character above with a solid pipe character before use. Posting on this forum changes that character. [/added]