# Remove ‘public’ from url using .htaccess

If you don’t have SSH access to your server or for any reason you cant configure the domain root to the `public` directory, the `.htaccess` can be your ultimate tool to remove `public` from URL.

On the zCart rood directory create a .htaccess file and add below content:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    RewriteCond %{REQUEST_URI} !^/public/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /public/$1
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    RewriteRule ^(/)?$ public/index.php [L]

Now change `example.com` to `yourdomain.com` on the 2nd and 7th line and save the file.

HELP! A `.htaccess.example` file is included. Just rename the file to `.htaccess` and modify it to make it yours.

Was this page helpful?
Yes No

### How can we improve this documentation?

### Leave Comment Cancel reply

You must be logged in to post a comment.