The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Simple .htaccess hack? www.blank.com to blank.com

powersspowerss Registered User regular
edited July 2007 in Help / Advice Forum
So, for our cookie system, we want it so whenever you visit our site, regardless of what you've entered, you get directed to a "blank.com" and not a "www.blank.com.

I.e, you want to go to blank.com. You type www.blank.com but in your title bar it changes to http://blank.com.

Help?

powerss on

Posts

  • JaninJanin Registered User regular
    edited July 2007
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
    RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
    

    Janin on
    [SIGPIC][/SIGPIC]
  • powersspowerss Registered User regular
    edited July 2007
    do I throw that in the .htaccess file?

    powerss on
  • JaninJanin Registered User regular
    edited July 2007
    powerss wrote: »
    do I throw that in the .htaccess file?

    Yeah, but be sure you've enabled mod_rewrite first. You might also have to tweak your AllowOverride settings if you've not given permission for .htaccess files to define rewrite rules.

    Janin on
    [SIGPIC][/SIGPIC]
  • telcustelcus Registered User regular
    edited July 2007
    powerss wrote: »
    I.e, you want to go to blank.com. You type www.blank.com but in your title bar it changes to http://blank.com.

    Using .htaccess and mod_rewrite won't change the users bar to reflect the fact that they're now looking at blank.com rather than www.blank.com, as mod_rewrite is an internal redirection.

    If you want the user to see that they're looking at blank.com rather than www.blank.com, a simple redirect page is the easiest way to do this. For example, www.arstechnica.com sends back a 301 Moved Permanently with a location of arstechnica.com in its HTTP headers. In PHP, using the header() command can change these codes to get a redirect going.

    telcus on
    [SIGPIC][/SIGPIC]
  • JaninJanin Registered User regular
    edited July 2007
    telcus wrote: »
    powerss wrote: »
    I.e, you want to go to blank.com. You type www.blank.com but in your title bar it changes to http://blank.com.

    Using .htaccess and mod_rewrite won't change the users bar to reflect the fact that they're now looking at blank.com rather than www.blank.com, as mod_rewrite is an internal redirection.

    If you want the user to see that they're looking at blank.com rather than www.blank.com, a simple redirect page is the easiest way to do this. For example, www.arstechnica.com sends back a 301 Moved Permanently with a location of arstechnica.com in its HTTP headers. In PHP, using the header() command can change these codes to get a redirect going.

    The [R=301] flag to RewriteRule forces an HTTP 301 code to be returned, which will properly update the user's browser.

    Janin on
    [SIGPIC][/SIGPIC]
Sign In or Register to comment.