1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

.htaccess question

Discussion in 'BlackHat Lounge' started by smoker450, Jun 20, 2012.

  1. smoker450

    smoker450 Newbie

    Joined:
    Dec 18, 2011
    Messages:
    30
    Likes Received:
    6
    Hi there,

    I want to buy a domain, domain.com
    I want to put something in my .htaccess file that redirects any url with that domain to the homepage.
    exapmple: domain.com/test when they click that I want them to go to domain.com because domain.com/test does not exist.
    I want to be able to use many variations of domain.com/test1, domain.com/test2, domain.com/test3 etc without having to create all the directories and using a php/html redirect.

    I am pretty new to this and my technical lingo isnt perfect, so please dont laugh if I sound like a dummy. Thanks.
     
  2. BleuMunkiGraphics

    BleuMunkiGraphics Junior Member

    Joined:
    Jun 13, 2012
    Messages:
    155
    Likes Received:
    26
    Occupation:
    Graphic Designer
    Location:
    Houston,Texas
    you don't really have to use htaccess in a coding manner... but use your cPanel to change it. HG has an option to edit your htaccess file, without the coding. Its simple point and click. but heres something to look at if you really want to play with it.
    Code:
    [COLOR=#111111][FONT=Tahoma][I]<IfModule mod_rewrite.c>[/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]RewriteEngine On[/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]RewriteBase /[/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]RewriteCond %{REQUEST_FILENAME} !-f[/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]RewriteCond %{REQUEST_FILENAME} !-d[/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]RewriteRule . /index.html [L][/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]</IfModule>[/I][/FONT][/COLOR]
     
    • Thanks Thanks x 1
  3. smoker450

    smoker450 Newbie

    Joined:
    Dec 18, 2011
    Messages:
    30
    Likes Received:
    6
    Thanks Bleu, I have fatcow and they do not use cpanel. I was following a tutorial from a friend and was directed towards the htaccess method.

    sorry to be so new, but i don't know what to do with the following code.

    Code:
    [COLOR=#111111][FONT=Tahoma][I]<IfModule mod_rewrite.c>[/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]RewriteEngine On[/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]RewriteBase /[/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]RewriteCond %{REQUEST_FILENAME} !-f[/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]RewriteCond %{REQUEST_FILENAME} !-d[/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]RewriteRule . /index.html [L][/I][/FONT][/COLOR]
    [COLOR=#111111][FONT=Tahoma][I]</IfModule>[/I][/FONT][/COLOR]
     
  4. antx16

    antx16 Power Member

    Joined:
    Nov 25, 2007
    Messages:
    672
    Likes Received:
    1,536
    simple line to redirect 404

    Code:
    ErrorDocument 404 http://www.Domain.com/
     
    • Thanks Thanks x 1
  5. smoker450

    smoker450 Newbie

    Joined:
    Dec 18, 2011
    Messages:
    30
    Likes Received:
    6
    gotcha, because if they go to a address that does not exist, I need to redirect that error to domain, got it, thanks so much.

    I was going to try 301, but if they click on an address that is not there, they would get the 404?

    I learned more than just the little line of code, that opened my eyes to how other things work. Thanks again.
     
  6. BleuMunkiGraphics

    BleuMunkiGraphics Junior Member

    Joined:
    Jun 13, 2012
    Messages:
    155
    Likes Received:
    26
    Occupation:
    Graphic Designer
    Location:
    Houston,Texas
    they wouldn't get the 404 if you use the code he gave you. it would just send you back to the main page
     
  7. antx16

    antx16 Power Member

    Joined:
    Nov 25, 2007
    Messages:
    672
    Likes Received:
    1,536
    Glad that was of help guys, its a useful line for many problems