Support » How-To and Troubleshooting » .htaccess redirection

.htaccess redirection

  • Hi there!

    As many others, I am trying to proceed to a site redirection. I found many answers but none of them is working correctly. Let me explain.

    In my “public_html” folder, I have two sites : my personal site and my wiki. Both of them are differents. Obviously, they share the same URL :

    Currently, my “www.mysite.com” is nothing more than a “403 error”.

    What I want is a redirection from “www.mysite.com” to “www.mysite.com/site”. I could do it through the “.htaccess” file located in the “public_html” folder, by typing :

    RewriteEngine On
    RewriteRule ^(.*)$ http://www.mysite.com/site/$1 [L,R=301]

    BUT, if I do this, I just can’t go to my “www.mysite.com/wiki” because it is automaticly redirected to “www.mysite.com/site/wiki” and obviously does not exist.

    Can I do it through “.htaccess” ? Why not using a “If” query ?
    Can someone help me good ?

    Thank you guys.


Viewing 3 replies - 1 through 3 (of 3 total)
  • Josh


    Moderator and Editor Customizer

    Why not just setup a redirection in your cpanel from www.mysite.com/site to www.mysite.com/wiki?

    Are these setup as subdomains on your host?


    Not sure to know how to setup a redirection as you told me.

    If I get it correctly, yep on my host folder I have two independant subdomains : /site & /wiki

    There are both differents. Maybe it was a mistake to use two different entities for this purpose.


    The rewrite rule is fine, however it needs a condition in order to work properly as you don’t want to mess with the pages under /wiki/

    Try this:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^wiki/
    RewriteRule ^(.*)$ http://www.mysite.com/site/$1 [L,R=301]

    Actually both sites have not the same url, they have just the same host, and they are not actually subdomains, just subdirectories. Handling the right concepts would help you to understand better how to implement rewrite rules and other fancy tricks you could get inspired later.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘.htaccess redirection’ is closed to new replies.