Get exclusive CAP network offers from top brands

View CAP Offers

Protect your domain from hijacking

[bsa_pro_ad_space id=2]
  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #588916
    Anonymous
    Inactive

    We’ve discussed the perils of using the www and non-www versions of your domain here before, but I’ve never considered the possibility of malicious webmasters using it to sabotage your site.

    An article today at Threadwatch points out how to redirect your non-www domain to the regular www version and insure that you’re safe.

    http://www.threadwatch.org/node/2817

    However, the mod_rewrite hacks there seem to add an extra slash in the redirect. Here’s a better version from the Apache URL Rewriting Guide:

    Code:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.domain.com [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/(.*) http://www.domain.com/$1 [R=301,L]
    #667132
    Anonymous
    Guest

    thanks Ken,

    for us real challenged, can you explain where that code should be inserted?

    for example, should it go on our index page? all pages?

    and does it go in the head section? (I assume).

    please add any other info I need to know and probably don’t. :)

    thanks again

    S.

    #667137
    Anonymous
    Inactive

    Go to your hosting CP – Website Settings – Custom Settings (Apache Config), or if you have acces to your .htaccess – just add this commands.

    #667159
    Anonymous
    Inactive

    I realized when I posted this that I wasn’t giving all the information really necessary. The reason was that I knew the way I installed it on my system would be different from virtually everyone else, and I wasn’t sure about how to install it for everyone else.

    (I run Plesk on my server, so I installed this in /home/httpd/vhosts/domain.com/conf/vhost.conf, and then had to run
    /usr/local/psa/admin/sbin/websrvmng –reconfigure-vhost –vhost-name= )
    But that’s only if you are running Plesk (a hosting control panel).

    vd752’s description of where to put it looks fine to me. For the htaccess solution, I believe the file must be named ‘.htaccess’ and placed in the root directory where your content resides. Someone please correct me if I’m wrong. I’m sure you can find more detailed instructions by Googling htaccess.

    You’ll probably have to restart Apache afterwards for this to take effect.

    #667161
    Anonymous
    Inactive

    I think the coding above is incorrect. I think it’s redirecting from http://www.example.com to http://www.example.com. Someone double-check please? (It should, unless I misunderstand, redirect from http://example.com to http://www.example.com.)

    #667166
    Anonymous
    Inactive

    Yes there is an error in that code.

    This is what i have in my .htaccess file and it works fine.

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mysite.com$ [NC]
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]

    #667167
    Anonymous
    Inactive

    Both my example and cyclone’s will work.
    In my example, note the exclamation mark in the RewriteCond lines.
    The line RewriteCond %{HTTP_HOST} !^http://www.domain.com [NC]
    means match anything that does NOT start with http://www.domain.com

    #667169
    Anonymous
    Inactive

    Yours worked for me, Ken.

    Thanks!!!

    #667170
    Anonymous
    Inactive

    Very cool to know. Thanks.

    BlackjackInfo wrote:
    Both my example and cyclone’s will work.
    In my example, note the exclamation mark in the RewriteCond lines.
    The line RewriteCond %{HTTP_HOST} !^http://www.domain.com [NC]
    means match anything that does NOT start with http://www.domain.com
    #667173
    Anonymous
    Inactive

    I guess there wasn’t an error then, i didnt know about exclamation mark.

    #667183
    Anonymous
    Inactive

    Hi,
    one quick question. Currently trying to install the code, but having some problems. Which parts of the code need to be edited?


    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^http://www.domain.com [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/(.*) http://www.domain.com/$1 [R=301,L]

    Only the domain name, or also anything else? Can I place this code anywhere in the .htaccess file, or does it have to be in a specific spot?
    I’m still very new to this stuff!

    Thanks for your help,

    burgi

    #667187
    Anonymous
    Inactive

    Ok, I got it to work, but I used cyclone’s code because I was not able to get the other code to work (probably too stupid to get it done). lol

    Thanks,

    burgi

    #667191
    Anonymous
    Inactive
    burgi82 wrote:
    Ok, I got it to work, but I used cyclone’s code because I was not able to get the other code to work (probably too stupid to get it done). lol

    Thanks,

    burgi

    Same here.

    #667335
    Anonymous
    Inactive

    Hi all,

    I’ve been messing around with this .htaccess trick for about an hour now, and I can’t seem to get anything to happen. I tried the examples from both Ken and cyclone.

    I go into my Control Panel, and then I go to the Website Files and Scripts section where I can edit the .htaccess file. I have two options: Add Rule, or Edit Manually. I selected Edit Manually so I could just copy and paste the code into the text box.

    I pasted the code, changed the dummy URLs to my own URL, and then saved the file.

    Now when I go and type my url in the address bar without the www, I expect it to redirect to the www version, but it doesn’t. Isn’t that what it’s supposed to do?

    Any ideas on what I’m doing wrong here? Do I need to stop and restart the server or something?

    Here are the exact two methods I tried:

    [HTML]
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^onlinepokercraze.com [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/(.*) http://www.onlinepokercraze.com/$1 [R=301,L]
    [/HTML][HTML]RewriteEngine On
    RewriteCond %{HTTP_HOST} ^onlinepokercraze.com$ [NC]
    RewriteRule ^(.*)$ http://www.onlinepokercraze.com/$1 [R=301,L][/HTML]Thanks guys.

    #667337
    Anonymous
    Inactive

    Yes, you’ll need to restart Apache for the change to take effect.
    Hope that works for you.

Viewing 15 posts - 1 through 15 (of 18 total)