Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

How to remove string from url or is there any option to have base url?

Started by Muut Archive 10 years ago · 8 replies · 649 views
10 years ago

I have page http://truhlarstvimertl.cz/ where home page is on http://truhlarstvimertl.cz/domains/truhlarstvimertl.cz/. I want to get rid of that "/domains/truhlarstvimertl.cz" string but there is no option like in wordpres to rewrite url.

This is because grav is not installed in root folder but it is in www/domains/truhlarstvimertl.cz/
Also i tried to play with .htacces, but no success.

Hope you understand my problem, it is little bit complicated :)

10 years ago

I'm thinking about editing the Uri.php the function buildHostname()

10 years ago

There seems to be one .cz host that has this requirement. It's come up 3 times now, and only ever for .cz domains with this very specific URL format. No other host we have ever come across has had these issues.. Just this one.

As we don't have an account there, and no real way to test it's a bit hard for us to quickly replicate and fix the issue. If you can help that would surely be appreciated. A PullRequest with a fix would be awesome!

10 years ago

Thanks for answer. Yea, this provider is wedos.com (from czech rep.) and i hate this format of URL. In wordpress it is solved by changing site URL in administration https://codex.wordpress.org/Changing_The_Site_URL. I don't really know where to start to write some rules in Grav. Do you have any suggestions or tips how this can be made? I would like to fix this issue, because i fell in love with grav!

10 years ago

This is the solution:
https://github.com/getgrav/grav/issues/783
Change uri.php (system/src/Grav/common/):

From:
$root_path = str_replace(' ', '%20', rtrim(substr($_SERVER['PHP_SELF'], 0, strpos($_SERVER['PHP_SELF'], 'index.php')), '/'));

To:
$root_path = str_replace(' ', '%20', rtrim(substr($_SERVER['REQUEST_URI'], 0, strpos($_SERVER['REQUEST_URI'], 'index.php')), '/'));

10 years ago

I have tested it and it works fine, until i try to login.
Repro:

  1. Go to domain.com/admin
  2. Fill your name and password
  3. Hit login

Actual behaviour:
Url looks like this "admin/"
And it throws this error:
405 - HTTP verb used to access this page is not allowed.
Error screen

10 years ago

On the frontend it's working fine? Just admin gives issues?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1368 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago