How can I remove /public and the name from URLs in Bolt?

571 Views Asked by At

I'm working on a small site and I've got a question. How can I remove the /public and the singular name from url? However for the entries I want to keep the first segment.

How do I do that? Because when I try to rewrite it in the htaccess the assets break (images etc)

3

There are 3 best solutions below

0
On BEST ANSWER

Use .htaccess file to rewrite your URL's:

<IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^(.*)$ public/page [L] </IfModule>

0
On

The public part of the url should not be visible if you have your Apache virtualhost setup correctly.

Ordinarily, all you need to do here is point the DocumentRoot setting to the public directory, so for example if your setup currently looks like this: DocumentRoot /home/mysite

You adjust it to: DocumentRoot /home/mysite/public

You may also need to do the same for any <Directory /home/mysite > commands that are in your config too.

Once you have amended, restart Apache and http://yourdomain.com/ should load up the homepage and http://yourdomain.com/bolt take you to the backend.

1
On

You need to point your server to the /public directory. Here is what the official documentation is saying:

Only the 'public' folder needs to be accessible in the browser. After the first installation this folder is named public/ but as you read on, you will see that you can rename it to www/ or whatever your web server requires. To do this, configure your webserver to use the public/ folder as the web root. For more information about this, see the pages on configuring Apache or Nginx.

Source: https://docs.bolt.cm/3.2/installation/install-command-line

The directive for Apaches VirtualHost is (in your example domaincom.conf in /etc/apache/sites-enabled:

<VirtualHost *:80>
  DocumentRoot /your-bolt-directory/public
</VirtualHost>

And for Nginx:

location / {
    root /your-bolt-directory/public;
}