Changing the site URL breaks everything

Hello Everybody.

I’m new to Grav.
Installing (most recent version + the admin plugin) went very smoothly.

Grave was installed in mydomain. com/grav (which in cPanel is actually public_html/grav) and I had no issues logging in at mydomain. com/grav and experimenting with some content.

I would, however, eventually want to access the website from mydomain. Therefore, I decide to try and see if changing the URL works.
I followed the instructions for changing the here and everything broke. I double-checked the changes and there are no typos or anything like that.
I’ve then found this discussion of the same issue, but:

  1. For organizationl purposes I’d prefer to leave Grav inside its own directory.
  2. I already unconnected RewriteBase and changed it to: RewriteBase /grav
    Everything is still broken.

I would appreciate any help.

Thank you.

Did you clear all caches in admin-panel? Had the same issue recently and then found out I did not clear the cache.

Now that I think of it, I don’t believe that I did.
I’ll give this a try and report back.
Thank you for your help.

Because I can’t access the admin panel, I deleted the content of the /cache directory.
Doesn’t seem to have solved the problem.
Do you happen to know if cache or cache-related data is stored anywhere else?

@shai, Have you tried running your site on your localhost to rule out server config issues?

I tried the following:

  • Windows Subsystem for Linux running Ubuntu 18.04. Webserver Apache.
  • Website can be accessed as http://localhost/grav/site-dev
  • After following the docs you referred to, I can access it using http://localhost. Pages and Admin are working fine.

Thanks for the good suggestion. I haven’t, but will give it a try.

Some progress.
I’ve set up a local dev environment (Apache and PHP running in Laragon).
Changing the URL from ‘http://localhost/grav’ to ‘http://localhost’ works locally in the sense I can access the website. However, the website seems to have lost the layout and perhaps not all buttons are working either.

For example, the is how the Admin panel looks at the moment:

I tried clearing cache several times (including browser cache) but nothing has changed. Any idea?

@shai, At least something has changed…

Ok, down to basics… Like, “Is the powercord plugged in”.

  • Create a fresh installation of Grav 1.6.23 + Admin in subfolder ‘/grav’ in the root of your localhost website. Don’t add your own stuff…
  • Test the website using http://localhost/grav and Admin at http://localhost/grav/admin
  • If all works fine, follow the steps in the documentation: Scenario 1, run in the domain root folder:
    • Add the following to ‘/user/config/system.yaml’:
      custom_base_url: 'http://localhost'
      session:
        path: /
      
    • In the root of localhost (the folder above ‘/grav’) add the ‘.htaccess’ file with only the following content:
      RewriteEngine On
      RewriteCond %{REQUEST_URI} !^/grav/
      RewriteRule ^(.*)$ /grav/$1
      
  • Test the website using http://localhost
  • Things I’ve seen going wrong:
  • If after checking the ‘.htaccess’ in the folder above ‘/grav’ and site is still not working then I have no more suggestions at the moment…

Thank you very nuch for all your help so far.
What you describe is exactly what I did, I think. However, I did everything somewhat in a hurry and maybe overlookef something (I’m not a developer and basically looking to set up a small personal website, though I enjoy setting things up myself even if sometimes I nneed to cath-up on knowledge).
I’ll start again from the beginning, as you suggest.

Update.
I’ve started completely from scratch and tested on Ubuntu 20.04.
I got it to work, sort of.
Now ‘mydomain.com/grav’ directs to ‘mydomain.com’, but trying to access the admin panel results in an empty page.
I’ll try to investigate further. Maybe it’s a cache issue. I’m not sure.

It is probably not a cache issue.

Do you have access to the CLI and/or the webserver configuration?

If you have access to CLI, then install Grav from scratch in directory public_html, which looks like the is set up as your site’s DocumentRoot by the default webserver configuration.

If you have access to the webserver configuration, change its DocumentRoot to point to public_html/grav.

If you have access to neither, but are supposed to use cPanel, my recommendation is to find a new hosting provider that gives you a VM where you access to the CLI, and let you configure the webserver yourself (YYMV).

I ran into my initial problem running on a shared hosting plan with cPanel.
I had no SSH access nor any other control on the server.

Installing directly into public_html worked but not when I tried to install into public_html/grav.

I then moved to testing locally, first using Laragon and then going directly with Ubunto and creating an Apache server. I still run into issues. Once I’ve made all the changes to the system.yaml and .htaccess files to point from mydomain .com/grav to mydomain .com, mydomain .com was accessible (which was progress because on the shared hosting server nothing had worked after trying to change the URL) but mydomain .com/admin did not. I ended up with a blank webpage.

I still haven’t figured it out because other priorities took over my time but I’m probably doing something wrong.
I also tried this on Ngnix and got it to work.

My plan is to eventually get a VPS on Vultr/Linode and probably run the Grav installation on Nginx. This was just a preliminary experiment/testing to make sure I will be able to get the installation to work and handle maintaining the server (which is my biggest concern). I’m not a developer and this is a personal project that I’m also using as a learning experience.

If you get a blank webpage (aka. White Screen Of Death or just WSOD) on a fresh Grav install, check file system permissions.

For what it is worth, here is a link to my notes on installing Grav on an Ubuntu 18.04 LTS server. It tells you how to install grav in the document root by means of a skeleton (recommended) or by using composer (only recommended if you’re familiar with the composer dependency manager).

Thank you, gisle.
File permissions is the one thing I haven’t thought about as a possible cause for not being able to access the Admin panel.
The Admin panel was accessible and worked when installed in the root directory but not in a /grav directory, and it didn’t occur to me file permissions might have changed/need to be changed.
I’ll have a look at your notes over the weekend.
Thank you very much for your help.