Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Redirect to subfolder. Disallow direct subfolder access

Discussion in 'Bind/DNS/Nameserver' started by codplay, Jul 24, 2017.

  1. codplay

    codplay Registered

    Joined:
    Jul 24, 2017
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    united states
    cPanel Access Level:
    Website Owner
    Folder structure

    -public_html

    -magsandbox
    -app
    - pub
    - ....

    -magstage
    -app
    - pub
    - ....

    -magquality
    -app
    - pub
    - ....
    In public_html/.htaccess, I have following rule

    RewriteCond %{HTTP_HOST} ^domain.com$ [NC,OR]
    RewriteCond %{HTTP_HOST} ^www.domain.com$
    RewriteCond %{REQUEST_URI} !magstage/
    RewriteRule (.*) /magstage/$1 [L]
    This has been working perfectly so far. domain.com redirect to domain.com/magstage behind the scenes and my site is accessible.

    But from SEO perspective I have a duplication issue.

    domain.com and domain.com/magstage are both accessible for crawling and both are the one and same magento installation.

    How can I allow the redirect to subfolder but at the same block the subfolder access?

    I tried various combination adding htaccess in root as well as in subfolder. either the site goes down OR goes in a loop with both redirecting to each other.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,700
    Likes Received:
    1,791
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    codplay likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice