Zen Cart Logo
Forums / General Questions / .htaccess help!

.htaccess help!

Locked

Views: 1,279

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
16 Oct 2010, 11:29 AM
#1
gamenet avatar

gamenet

Zen Follower

Join Date:
Apr 2010
Posts:
149
Plugin Contributions:
0

.htaccess help!

Hi. I am trying to re direct my URLS to one particular one.

In order to do this i need to use a 301 redirect. i tried changing my .htaccess file.

Contents of .htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^gamenet.net.au/?$ "http://gamenet.net.au/" [R=301,L]

redirect 301 http://gamenet.net.au/ http://www.gamenet.net.au/

I tried adding the bottom line of code to redirect http://gamenet.net.au/ to http://www.gamenet.net.au/ however when i type in the first url it does not re-direct my to the latter.

I am not sure that i used the correct code. could someone please help me out? it would be greatly appreciated. Thanks!

16 Oct 2010, 11:35 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: .htaccess help!

Try this

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.your_domain.com$
RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]
16 Oct 2010, 11:55 AM
#3
gamenet avatar

gamenet

Zen Follower

Join Date:
Apr 2010
Posts:
149
Plugin Contributions:
0

Re: .htaccess help!

mmm i am a bit confused. could you please insert my two URLs i am wanting to redirect into that code? thanks :)

16 Oct 2010, 12:06 PM
#4
gamenet avatar

gamenet

Zen Follower

Join Date:
Apr 2010
Posts:
149
Plugin Contributions:
0

Re: .htaccess help!

RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^gamenet.net.au/?$ "http://gamenet.net.au/" [R=301,L]

RewriteEngine on
RewriteCond %{HTTP_HOST} !^http://gamenet.net.au/$
RewriteRule ^(.*)$ http://www.gamenet.net.au/$1 [R=301]

I added that code. and look what it did.
gamenet.net.au

16 Oct 2010, 12:13 PM
#5
gamenet avatar

gamenet

Zen Follower

Join Date:
Apr 2010
Posts:
149
Plugin Contributions:
0

Re: .htaccess help!

Please help. i want to fix it urgently.

16 Oct 2010, 12:41 PM
#6
gamenet avatar

gamenet

Zen Follower

Join Date:
Apr 2010
Posts:
149
Plugin Contributions:
0

Re: .htaccess help!

I could not leave my site like that so here is what is said.

The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Do you have any idea what i did wrong?

Sorry - for the multiple posts.

16 Oct 2010, 2:56 PM
#7
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: .htaccess help!

Try this code, exactly as is.

RewriteEngine ON

RewriteCond %{HTTP_HOST} ^gamenet.net.au [NC]
RewriteRule ^(.*)$ http://www.gamenet.net.au/$1 [R=301,NC,L]

16 Oct 2010, 3:39 PM
#9
linnx avatar

linnx

Zen Follower

Join Date:
Jun 2009
Posts:
187
Plugin Contributions:
0

Re: .htaccess help!

I'm not sure if this is what you need, but using a free mod like this http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=231 should take you on the right path. If you go to the free zen cart addons and search for SEO you will see some more mods that re-write the standard url's to something more SEO friendly. I think one of them allows you to do something like /xbox360 but I could be wrong.

gamenet:

you sir. are a genius.

Would you be kind enough to explain a bit on how you did it. with the "/" etc.
i am wanting to add another one to the equation. this time i'm trying to change

http://www.gamenet.net.au/index.php?main_page=index&cPath=106

to somethign like

http://www.gamenet.net.au/xbox360

16 Oct 2010, 3:50 PM
#10
gamenet avatar

gamenet

Zen Follower

Join Date:
Apr 2010
Posts:
149
Plugin Contributions:
0

Re: .htaccess help!

Yes, that is somewhat what i am after, however i would much prefer to be able to code it myself, like rob just did :)
Thanks tho! :)

16 Oct 2010, 5:10 PM
#11
website_rob avatar

website_rob

Inactive

Join Date:
Oct 2006
Location:
Alberta, Canada
Posts:
4,572
Plugin Contributions:
0

Re: .htaccess help!

Glad the code helped. There are variations of doing the same thing and the code provided earlier by Kobra could have worked as well but I noticed you had not copied it exactly as described.

For rewriting all URLs and/or creating 'pretty urls' you are better off to use the module suggested by linnex.