• Symon83

    (@symon83)


    Hi guys,
    I have a website, in this path public_html/TEST
    and the .htaccess in this path public_html/.htaccess
    This is the htaccess:

    RewriteOptions inherit
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /TEST/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /TEST/index.php [L]
    </IfModule>
    
    # END WordPress

    So, the url of my website is
    https://www.mywebsite.com/TEST

    The website is live and i need to set up these condition:

    1) I need the url is https://www.mywebsite.com (I need to keep the files in the folder TEST )
    2) I have to redirect https://www.mywebsite.com/TEST to https://www.mywebsite.com
    So i guess for the point 2, i have just to do a redirect 301.

    Could anyone help me with the point 1 please?
    Many thanks
    Simone

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

    (@adiant)

    Here is the page to read:
    https://codex.www.ads-software.com/Giving_WordPress_Its_Own_Directory

    I strongly recommend that you consider an alternative approach, described in the “Using a pre-existing subdirectory install” section of the same page. I’ve been using it for about 6 years now, and find it much more flexible, less error-prone, etc.

    Thread Starter Symon83

    (@symon83)

    Hi thanks for your answer.

    I definitely changed my mind.

    Now i made a copy of the website and the db in the main root public_html.

    So i have 2 copy of the website, both working. How can i redirect properly with 301 wordpress from

    https://www.mywebsite.com/TEST
    to
    https://www.mywebsite.com

    I used a simple .htaccess in the folder /TEST
    redirect 301 / https://www.mywebsite.com

    but it redirect the website wrong with this result:

    typing https://www.mywebsite.com/TEST
    i get
    https://www.mywebsite.comTEST

    Is there any better option to redirect? please

    RewriteOptions inherit
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /TEST/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /TEST/index.php [L]
    </IfModule>
    
    # END WordPress

    this is the original htaccess in the folder /TEST
    thanks

    adiant

    (@adiant)

    As I said, I hate playing around with .htaccess except to set php options on web servers that don’t allow php.ini changes.

    The aforementioned “Using a pre-existing subdirectory install” section explains a much cleaner way to handle things: have just one copy of WordPress, installed in a folder, and have all the links look like you are “running from the root”.

    There are plugins that change all your links for you, avoiding the need to do any redirections in .htaccess.

    Again, just my experience and opinion.

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