Redirecting url to access subdirectory

I have a wordpress subdirectory install in a directory called ‘wordpress’. So currently I am able to access the live site as follows: www.domain.com/wordpress.

My objective is for users to simply navigate to: www.domain.com, omitting the wordpress directory from the url.

Read More

I was wondering if someone can help me configure my .htaccess so every time a user navigates to anything with domain.com/wordpress it’ll redirect to domain.com.

So for example: domain.com/wordpress/admin will become domain.com/admin

I created a new .htaccess file and placed in the root with the following contents, which did not work :

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^(/)?$ wordpress [L]

Related posts

Leave a Reply

1 comment

  1. To rewrite / to /wordpress you can use this rule :

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
    RewriteCond %{REQUEST_URI} !^/wordpress
    RewriteRule ^(.*)$ /wordpress/$1 [L]
    

    This will internally redirect all requests from root to the subfolder.
    Do not remove the RewriteCond directive otherwise the the rewrite destination will rewrite back to itself causing an infinite loop error.