Welcome to WebmasterWorld Guest from 3.84.139.101

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

htaccess file

url hiding

     

chris99099

3:10 pm on Nov 28, 2003 (gmt 0)

Inactive Member
Account Expired

 
 


Hi all,

I have a website let's say www.test.nl and I want it redirected to www.test.com but i want the url www.test.nl to stay in the address bar.

What do I need to put in the htaccess file to get this working?

Anyone?

4:16 am on Nov 29, 2003 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


chris99099,

Welcome to WebmasterWorld [webmasterworld.com]!

If both domains are pointed to same 'account' on one server, you can use mod_rewrite to do internal redirects when needed.

If they are on different servers, you can either change the DNS to point both domains to the same server and proceed as above, or you can display the pages from the 'real' site inside an iframe on the 'alias' site. However, that approach may break some of your navigation, and so should be tested thoroughly. It may only work for MSIE browsers, too.

Introduction to mod_rewrite [webmasterworld.com]

Jim

4:59 am on Nov 29, 2003 (gmt 0)

Full Member

10+ Year Member

joined:Oct 6, 2003
posts:264
votes: 0


Jim a little of topic, but using modrewrite to serve t2.html when t.html is called.
The user will see the page t2 successfully, but my question is why does the page name still stays same as abc.com/t.html?
Is it the case where both resides in the same directory?
6:00 am on Nov 29, 2003 (gmt 0)

Senior Member

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

joined:Mar 31, 2002
posts:25430
votes: 0


operafan,

Not really off-topic for the original question... :)

There are two ways to modify requested URIs using mod_rewrite: internal rewrites, and external redirects.

Internal rewrites are 'silent', that is, no sign of the change is visible to the user. Rewrites can only be done 'inside' the server -- only the filename associated with the URL is changed, not the domain name. (Note that the filename does not need to have anything in common at all with the URL-path - we're just used to them being the same most of the time.)

Example:


RewriteRule ^foo\.html$ /bar.html [L]

Here, if a client requests the page (file) "foo.html", the server sends the content from the file "bar.html", and gives no indication at all that it used "bar.html" instead of "foo.html" for the filename.

---

External redirects are needed in order to change anything within the 'domain', such as changing www.example.org to www.example.com. For an external redirect, the server does not send the requested content to the client (browser or spider). Rather, it sends a short message saying, "301-Moved Permanently" using an HTTP status response header. The server may also include the new URL for the requested content (modern servers always do).

This 301 response *ends* the current HTTP transaction which was initiated by the client. However, the client browser or spider usually takes the new URL and immediately re-requests the content from the new address. Note that this is a completely-new HTTP transaction. (This is not obvious unless you study HTTP [w3.org], and not remembering this fact can result in massive confusion about many redirection and server security issues).

The address seen by the user will change as a result of the 301 server response, before the browser makes the new request.

External redirects are also used to let users and search engine spiders know that a page has been replaced, even if the domain does not change.

Examples:


# Redirect example.org to example.com (Both domains point to this server)
RewriteCond {HTTP_HOST} ^www\.example\.org
RewriteRule (.*) http:www.example.com/$1 [R=301,L]

# Redirect old.html page to new.html, and let the user see the redirect.
RewriteRule ^old\.html$ http:www.example.com/new.html [R=301,L]

Jim

6:48 am on Nov 29, 2003 (gmt 0)

Full Member

10+ Year Member

joined:Oct 6, 2003
posts:264
votes: 0


You put it so eloquently, all mods here seem to have that touch - descriptive.

Hope that can be acquired later in life for me :) .

So I understand now. Yes & I've checked the header & with inside redirect & it shows 200, while obviously with the R flag, it will show 301.

Thanks.