Need a 301

Mynarky

Junior Member
Joined
May 15, 2010
Messages
102
Reaction score
29
I keep trying to create a 301 to merge my www and non-www sites. I use godaddy as a host and moniker to carry my domain, and I cant get this to work. I've tried htacess and nothing. Is there a simple code to accomplish this?
 
Check if your .htaccess code is correct or not...

If you don't want to use www in your URL

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

If you want to use www in your URL

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

If you are still not getting it correct then it means you don't have permissions for it... It's called mod_rewrite rule... Ask your hosting service provider and they will solve problem for you...
 
I have another question on this topic.

How would I go about redirecting the .index.html file of a directory to just the directory name itself. For example:

www yoursite com/about-us/index.html would only show as www yoursite com/about-us/

When I try to change htaccess to do a redirect it gives me the error "Firefox has detected that the server is redirecting the request for this address in a way that will never complete."

I am using the code: "Redirect 301 /about-us/index.html hxxp://www yoursite com/about-us/"
 
Last edited:
I dont think you actually need a 301 for this, couldn't use just use masking.
 
Could be several reason... You may not have permission for mod_rewrite...

BTW different script need different way to solve that problem and you have to check your script... there are simple ways to solve this problem in many case otherwise you can always go back to .htaccess

I have another question on this topic.

How would I go about redirecting the .index.html file of a directory to just the directory name itself. For example:

www yoursite com/about-us/index.html would only show as www yoursite com/about-us/

When I try to change htaccess to do a redirect it gives me the error "Firefox has detected that the server is redirecting the request for this address in a way that will never complete."

I am using the code: "Redirect 301 /about-us/index.html hxxp://www yoursite com/about-us/"
 
I dont think you actually need a 301 for this, couldn't use just use masking.
No, actually this is one of the recommended uses of a 301. Even google says you should do it, as well as set up the prefered url in webmaster tools.

It sounds like the OP is just having trouble getting the syntax right.

...
I am using the code: "Redirect 301 /about-us/index.html hxxp://www yoursite com/about-us/"
@OP - that just doesn't look right. It looks like your trying to use an alias directive. For a mod_alias directive you have to use the status 'permanent' not '301'. Also I'm not sure if you should use the filename in this instance. If that's the case then it should be more like
Code:
Redirect /about-us http://www.yoursite.com/about-us
or
Code:
Redirect permanent /about-us http://www.yoursite.com/about-us
Of course that's if your on an apache server.
I use the mod_alias version myself sometimes, but it's usually recommended to use the mod_rewrite like what bizroot posted in his reply.

Also I'm not sure why you would want to do it for just one page. If your going to use a redirect for choosing between www or non-www url then you really should do it globally so it takes care of all your pages.
 
Last edited:
If you use wordpress, use thesis theme. You can make 301 redirect instantly. Additional, use with wp hide post plugins.
 
Last edited:
Back
Top