.htaccess question

smoker450

Newbie
Joined
Dec 18, 2011
Messages
30
Reaction score
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.
 
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 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]
 
simple line to redirect 404

Code:
ErrorDocument 404 http://www.Domain.com/
 
simple line to redirect 404

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.
 
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.
they wouldn't get the 404 if you use the code he gave you. it would just send you back to the main page
 
Glad that was of help guys, its a useful line for many problems
 
Back
Top