Results 1 to 7 of 7
  1. #1

    help question .htaccess redirect

    Hi all!

    I'm hoping someone can give me some help with .htaccess because I'm really struggling.
    I have my Zen Cart store located in a subdirectory so I'd like to redirect to the subdirectory when someone enters the main URI in to the browser.

    My Zen Cart is located in a subdirectory called /shop so I need to redirect www.mywebsite.co.uk to www.mywebsite.co.uk/shop.
    The reason I have it in a subdirectory is because in the future there will be a 'service' section to the website which I will be putting in a subdirectory called /service.

    In addition, I'd like to hide the subdirectory name from the browser too, if that's possible!

    To summarise, when someone enters www.mywebsite.co.uk in the their browser, I'd like to redirect to www.mywebsite.co.uk/shop but the browser address bar should only show www.mywebsite.co.uk.

    I don't even know if what I want to do is possible, but if someone could let me know either way I'd really appreciate it

    :)

  2. #2
    Join Date
    Nov 2007
    Location
    Woodbine, Georgia, United States
    Posts
    4,246
    Plugin Contributions
    58

    Default Re: .htaccess redirect

    Adding a future directory to the site is no reason NOT to have your Zen Cart in the root as it should be.

    Note that you are not permitted to "hide" the directory path as you asked. This is called cloaking and it will get you a Google penalty.

    ~Melanie
    PRO-Webs, Inc. since 2003 :: Zen Cart Hosting :: Zen Cart SEO – 12 Steps to Success
    **I answer questions in the forum, private messages are not conducive to a helpful community.

  3. #3

    Default Re: .htaccess redirect

    Thanks Melanie,
    I'll move it to the root.
    I've found a tutorial that shows me how.

    I had a feeling it wasn't the way to do it :)

  4. #4
    Join Date
    Nov 2007
    Location
    Woodbine, Georgia, United States
    Posts
    4,246
    Plugin Contributions
    58

    Default Re: .htaccess redirect

    Cheers

    ~Melanie
    PRO-Webs, Inc. since 2003 :: Zen Cart Hosting :: Zen Cart SEO – 12 Steps to Success
    **I answer questions in the forum, private messages are not conducive to a helpful community.

  5. #5
    Join Date
    Mar 2010
    Posts
    2
    Plugin Contributions
    0

    Default Re: .htaccess redirect

    I've got issue with zencart redirects. In short: zencart resides on www.site.com/shop and I want to move it to just www.site.com. Currently anybody hitting www.site.com will be forwarded to /shop folder where the cart is. Because I have lot of inbound links to /shop pages I want all of those to be 301 redirected to their counter parts on www.site.com where i copied the entire cart. I've played with many combinations in .htaccess in both the webroot and /shop folder but nothing got me what I needed. Any insights/advice? Here is the current .htaccess in /shop folder
    #### BOF SSU
    Options +FollowSymLinks -MultiViews
    RewriteEngine On

    # Make sure to change "test_site" to the subfolder you install ZC. If you use root folder, change to: RewriteBase /
    RewriteBase /

    # Deny access from .htaccess
    RewriteRule ^\.htaccess$ - [F]

    RewriteCond %{SCRIPT_FILENAME} -f [OR]
    RewriteCond %{SCRIPT_FILENAME} -d
    RewriteRule .* - [L]

    RewriteRule ^(.*) index.php?/$1 [E=VAR1:$1,QSA,L]
    #### EOF SSU

  6. #6
    Join Date
    Jun 2007
    Posts
    70
    Plugin Contributions
    1

    Default Re: .htaccess redirect

    All you need is to add following code after RewriteBase line:

    Code:
    RewriteRule ^/shop/(.*)$ http://www.site.com/$1 [R=301,QSA,L]

  7. #7
    Join Date
    Mar 2010
    Location
    UK
    Posts
    445
    Plugin Contributions
    0

    Default Re: .htaccess redirect

    Paths are localised when used with ModRewrite in .htaccess so the leading slash will not be there.

    Additionally, QSA is the default action and does not need to be mentioned. This would work:
    Code:
    RewriteRule ^shop/(.*) http://www.example.com/$1 [R=301,L]


    For efficiency, I'd modify it a bit more, and put the code in the /shop/ folder, so it is only parsed when the URL request actually contains /shop/ within. In that case the code would be:
    Code:
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    The above code MUST go in the /shop/ folder. In root it will cause an infinite loop.

    See also post #11 at http://www.zen-cart.com/forum/showth...=150620&page=2

 

 

Similar Threads

  1. v151 htaccess redirect
    By Kevin205 in forum General Questions
    Replies: 3
    Last Post: 10 May 2014, 11:11 PM
  2. v150 To Redirect or .htaccess or not
    By dochsa in forum General Questions
    Replies: 8
    Last Post: 10 Sep 2012, 07:13 PM
  3. htaccess Redirect syntax
    By hedron in forum General Questions
    Replies: 0
    Last Post: 23 Feb 2010, 02:57 AM
  4. Redirect with .htaccess?
    By BillNally in forum General Questions
    Replies: 2
    Last Post: 4 Sep 2006, 02:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg