getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.59k stars 1.41k forks source link

Grav adds domain at the end of the url path #416

Closed tibor closed 9 years ago

tibor commented 9 years ago

Hi there,

I was trying to install grav cms on my webspace and found an odd behaviour: When I’m browsing to mydomain.com I get redirected to mydomain.com/mydomain.com – grav shows up, but (of cause) just with the 404 error page.

mydomain.com/admin works fine, so it doesn’t seems to be a .htaccess issue (I tried also to uncomment RewriteBase /, but with no effort). If you have any idea what this is caused by, I’d be happy to hear.

rhukster commented 9 years ago

What version of Grav are you running? Also can you paste your current 'user/config/system.yaml' file? Did you make any modifications to the .htaccess ?

tibor commented 9 years ago

I’m using RC4 of Grav 1.0, my system.yaml looks like:

absolute_urls: false

home:
  alias: '/home'

pages:
  theme: antimatter
  markdown_extra: false
  process:
    markdown: true
    twig: false

cache:
  enabled: true
  check:
    method: file
  driver: auto
  prefix: 'g'

twig:
  cache: true
  debug: true
  auto_reload: true
  autoescape: false

assets:
  css_pipeline: false
  css_minify: true
  css_rewrite: true
  js_pipeline: false
  js_minify: true

errors:
  display: true
  log: true

debugger:
  enabled: false
  twig: true
  shutdown:
    close_connection: true

This is what my .htaccess looks like:

<IfModule mod_rewrite.c>

RewriteEngine On
## Begin RewriteBase
# If you are getting 404 errors on subpages, you may have to uncomment the RewriteBase entry
# You should change the '/' to your appropriate subfolder. For example if you have
# your Grav install at the root of your site '/' should work, else it might be something
# along the lines of: RewriteBase /<your_sub_folder>
##

# RewriteBase /

## End - RewriteBase

## Begin - Exploits
# If you experience problems on your site block out the operations listed below
# This attempts to block the most common type of exploit `attempts` to Grav
#
# Block out any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block out any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root homepage
RewriteRule .* index.php [F]
#
## End - Exploits

## Begin - Index
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
## End - Index

## Begin - Security
# Block all direct access for these folders
RewriteRule ^(.git|cache|bin|logs|backup)/(.*) error [L]
# Block access to specific file types for these folders
RewriteRule ^(system|user|vendor)/(.*)\.(txt|md|html|yaml|php|twig|sh|bat)$ error [L]
# Block all direct access to .md files:
RewriteRule \.md$ error [L]
# Block all direct access to files and folders beginning with a dot
RewriteRule (^\.|/\.) - [F]
# Block access to specific files in the root folder
RewriteRule ^(LICENSE|composer.lock|composer.json|nginx.conf|web.config)$ error [F]
## End - Security

</IfModule>

# Begin - Prevent Browsing and Set Default Resources
Options -Indexes
DirectoryIndex index.php index.html index.htm
# End - Prevent Browsing and Set Default Resources

I had also versions of .htaccess with uncommented RewriteBase / running, but with no effort. When I’m pointing my browser to any post directly, everything works fine (e. g. mydomain.com/home displays the standard home-page); the homepage doesn’t.

flaviocopes commented 9 years ago

I tried the above .htaccess & system.yaml but all is working fine.. what's your server setup?

tibor commented 9 years ago

Which information about the server setup would be helpful?

flaviocopes commented 9 years ago

Hosting name, PHP version, operating system, web server used

rhukster commented 9 years ago

As this has not been added to in nearly 2 weeks, i'm going to close this issue.

Anyway, this is really not a Grav bug, but a server setup issue. If you want help on this please join us on our Gitter.im chat room and we'll be glad to help find a solution!

Cheers!