Jump to content

TimeBomb

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Everything posted by TimeBomb

  1. From my experience, .htaccess redirect can't do exactly what you want it to (all by itself, anyway). Normally, when you want two domains to point to the same spot, you just set up another virtual host with Apache wherein the folder goes to the same location as the original domain, but the domain is the alternative domain. Alternatively, you may also try looking into Apache's ServerAlias directive. If you require a 301 redirect when the alternative domain name is used, you can send out the status code - 301 - through PHP. Look into the HTTP_HOST and REMOTE_HOST properties in the $_SERVER array in PHP, one of them should supply the information you need to detect exactly which domain name the user is viewing the website from. Using a simple conditional check, you can then optionally send out a 301 status code via: header("HTTP/1.1 301 Moved Permanently"); header("Status: 301 Moved Permanently"); // For FastCGI only I feel compelled to warn you about the correct usage of the 30x status codes. I have recently done quite a lot of research into the 301, 302, and 307 status codes for another project of mine. 301 should be used when an object has moved permanently. Thus nothing will ever be located where the old URL (i.e. where it moved from) is. 302 is the default for PHP's header function when using header("Location: http://example.com"); to redirect. It is a Temporary Redirect - in the HTTP/1.0 Status Code Definitions. In the latest, HTTP/1.1, 302 means Found and 307 means Temporary Redirect. The specific meanings between the 302 HTTP/1.0 and 307 HTTP/1.1 are slightly different as well. It all can be quite confusing, especially when knowing when to use them and when not to. The HTTP/1.1 Status Code Definitions can be found at: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html Google is also a powerful tool. Good luck.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.