Web Hosting Forum | Lunarpages


*
Welcome, Guest. Please login or register.
Did you miss your activation email?



Login with username, password and session length
February 09, 2012, 11:53:38 AM

Pages: [1]   Go Down
  Print  
Author Topic: 301 redirects in .htacces  (Read 1161 times)
fallon
Trekkie
**
Offline Offline

Posts: 10


« on: July 26, 2009, 10:08:23 PM »

I understand (enough to copy in the right commands at least) how to implement a http://skybyes.com to http://www.skybyes.com redirect. However I'm trying to kick my wife's website live. The site is http://www.skybyes.com/zen_cart and I'm having trouble figuring out how to redirect just www.skybyes.com to www.skybyes.com/zen_cart without killing any other non zen_cart URL's.

I've done a pile of googling and can find a lot of stuff for adding/removing www's and moving domain names, but nothing for redirecting the root domain to a subdomain. Can get anybody who helps a 30% off discount on her site. ;-)

Devin
Logged
Mitch
Berserker Poster
*****
Offline Offline

Posts: 12838


WWW
« Reply #1 on: July 27, 2009, 06:06:20 AM »

Give this a shot:

http://www.lunarforums.com/lunarpages_webhosting_help/redirect_addon_domain_to_sub_folder_show_original_url-t49172.0.html

 Thumbs Up
Logged

New to Web Site Hosting? Check Out the Lunarpages Blog Hosting Guide!


Follow us @lunarpages on Twitter!
Important Threads: Read This Before Posting! | Lunarforums Rules! | Mitch's Link of the Day!
Also, be sure to check out and subscribe to the Lunartics Blog and the Lunarpages Newsletter !

Need Web Hosting Help? Check out the Lunarpages Web Hosting Wiki. It has tons of tips, tutorials and resources!
MrPhil
Berserker Poster
*****
Offline Offline

Posts: 5083



« Reply #2 on: July 27, 2009, 08:30:26 AM »

Your terminology is confusing. Where is the subdomain? Is "zen_cart" just a subdirectory under the domain, or is there a real subdomain or add-on domain involved?

Assuming you have only www.skybyes.com, are you saying that you want URLs without any path or file to go to zen_cart/, and everything else be left alone? That should be easy enough. I think this should work:
Code:
RewriteEngine On
RewriteRule  ^$  /zen_cart/

I don't think you want a 301 (permanent) redirection, as Google et al. will stop listing www.skybyes.com and list only www.skybyes.com/zen_cart/. If you do want that, add [R=301] at the end of the RewriteRule.

By the way, you may want to consider changing 'zen_cart' to 'store' or 'shop' before you go live -- it looks more professional that way.
Logged

fallon
Trekkie
**
Offline Offline

Posts: 10


« Reply #3 on: July 27, 2009, 09:09:19 PM »

Skybyes.com is not the main domain, it's one of several addon domains I have on the account. I mis-stated the sub-domain, it's a directory or subdirectory.

Are edits to the .httaccess file instantaneous, do they take some time to take effect, or is it on the next restart?
Logged
fallon
Trekkie
**
Offline Offline

Posts: 10


« Reply #4 on: July 27, 2009, 09:41:59 PM »

Helps if you don't edit 2 different .httaccess files apparently.  Smile Edits in the root .httaccess and the one under the skybyes folder were throwing me off.

Code:
# Redirect http://skybyes.com to https://www.skybyes.com
RewriteCond %{HTTP_HOST} ^skybyes\.com
RewriteRule ^(.*)$ https://www.skybyes.com/$1 [R,L]

#Force skybyes.com to zen_cart directory
RewriteCond %{HTTP_HOST} ^www.skybyes.com$
RewriteCond %{REQUEST_URI} !^/zen_cart/
RewriteRule ^(.*)$ /zen_cart/$1

Seems to be doing the trick. Hides the zen_cart (at least initially until you start rooting through the store), forces the www. May fiddle around and completely cloak the zen_cart in the URL for the whole site now that I have a clue on setting up the mod_rewrite rules.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to: