Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to prohibit browser navigation to path of grav installed in subfolder? #2880

Closed
paulrudy opened this issue Apr 14, 2020 · 4 comments
Closed
Labels

Comments

@paulrudy
Copy link

If grav is installed as a subfolder /grav/ in web root mysite.com, an .htaccess in mysite.com can point to the grav installation. But for web admins on shared hosting without access to vhost config, it appears to be impossible to prevent browsers from visiting mysite.com/grav/ or mysite.com/grav/foo.

Assume that the install is within mysite.com/grav/, and add the following to the web root's .htaccess

RewriteCond %{REQUEST_URI} ^/grav$ [NC,OR]
RewriteCond %{REQUEST_URI} ^/grav/.* [NC]
RewriteRule ^grav(.*) $1 [L,R]

Entering mysite.com/grav/foo, mysite.com/grav/, or mysite.com/grav results in no change in the url displayed in the browser's address bar.

But with

RewriteCond %{REQUEST_URI} ^/notgrav$ [NC,OR]
RewriteCond %{REQUEST_URI} ^/notgrav/.* [NC]
RewriteRule ^notgrav(.*) $1 [L,R]

Entering mysite.com/notgrav/foo, mysite.com/notgrav/, or mysite.com/notgrav results in the expected change, where /notgrav is removed from the address bar url.

Using shared hosting without access to vhosts config means—I think—that the only way to handle this situation and exclude /grav/ paths from showing up in the address bar would be to edit the grav install's .htaccess. But this is a disadvantage, since grav updates will overwrite it. An advantage of having grav in a subdirectory is that all .htaccess can be done in the web root, so only /grav/user needs to be tended to.

I apologize in advance if I have missed some already-available solution. If not, I propose that a change be made to allow removing /grav from outward-facing mysite.com/grav/foo urls.

@rhukster
Copy link
Member

This is really a webserver config thing, not Grav.

@paulrudy
Copy link
Author

Thanks. I don't want to waste your time, and I might be misunderstanding something—but isn't it something in grav that is preventing .htaccess from rewriting paths with /grav/ (since it can rewrite any other path)?

@rhukster
Copy link
Member

rhukster commented Apr 22, 2020

Grav does control any path beneath the site.. i.e. /grav/some/folder and this is going to try to find a page that routes to that, if it doesn't find anything you are going to get a Grav issues 404. You can't remove the /grav part without the help of the webserver by setting up a vhost or similar as you mention.

You can however use the custom_base_url option in system.yaml to configure a different URL for the base of Grav. Perhaps this is what you are looking for?

@paulrudy
Copy link
Author

Ok, thanks for getting back to me. I had assumed it would be possible without a 404, since my previous Wordpress would remove any external-facing /wordpress/ from the browser url. I'll check with my hosting provider or move to vps if I decide it's a big enough deal for me. Setting custom_base_url: "mysite.com" doesn't change the behavior. Thanks again. It's a minor issue, really.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants