WordPress.org

Ready to get started?Download WordPress

Forums

.htaccess redirection (4 posts)

  1. Merenguey
    Member
    Posted 1 year ago #

    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 :
    - http://www.mysite.com/site
    - http://www.mysite.com/wiki

    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.

    M.

  2. 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?

  3. Merenguey
    Member
    Posted 1 year ago #

    Hi!

    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.

    M.

  4. Jesús Franco
    Member
    Posted 1 year ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic