Page 1 of 2

[SOLVED] Absolute vs Relative Paths

Posted: Wed Mar 15, 2017 10:23 am
by rnd1530
Hi, i had to change INC_ROOT', dirname(__FILE__)); by define('INC_ROOT', $_SERVER["DOCUMENT_ROOT"] );
Now i got an 500 Internal server error... learning htaccess...

Re: Absolute vs Relative Paths

Posted: Wed Mar 15, 2017 11:23 pm
by wiz
Hello rnd, have a warm welcome to the community.

Can you check if your function url is exactly like the one below? If not sure, simple replace it with the one pasted below.

Code: Select all

public static function url($location = null) { return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? > 'https://' : 'http://').$_SERVER['HTTP_HOST'].str_replace($_SERVER['DOCUMENT_ROOT'], '', str_replace('\', '/', > dirname($_SERVER['SCRIPT_NAME'])))."/{$location}"; }
Also, are you running / have hosting on a Windows IIS server?

Re: Absolute vs Relative Paths

Posted: Thu Mar 16, 2017 9:44 am
by rnd1530
Apache
This url function needs to remove 2 "greater than" symbols and missing 1 escape '\'

Code: Select all

public static function url($location = null)
 { return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 
            'https://' : 
            'http://').$_SERVER['HTTP_HOST'].str_replace($_SERVER['DOCUMENT_ROOT'], '', 
                           str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']) ) )."/{$location}"; 
  }
                           
then i get 'myserver.com//home'
and 500 Internal error.

Re: Absolute vs Relative Paths

Posted: Thu Mar 16, 2017 10:57 pm
by wiz
Thanks for the code fix, haven't seen a case where this wouldn't work.

What version of PHP are you running on, and have you made any changes to .htaccess?
Would you mind trying out the unreleased WonderCMS 2.0 https://github.com/robiso/wondercms-test and post the results?

Re: Absolute vs Relative Paths

Posted: Fri Mar 17, 2017 11:03 am
by rnd1530
PHP Version 5.6.30

This happened after i changed my hosting plan, maybe the providers modified something on php.ini.
The unreleased version gives me same error, i will try to fix this :) or try to back 0.x.x and check... next week will have more free time.

Nevermind, i like challenges :)

Re: Absolute vs Relative Paths

Posted: Fri Mar 17, 2017 11:33 am
by wiz
This is also extra weird since we do things a little bit differently in version 2.0, so the error should be at least in another line. Is there anything in your error log?

If it worked before you've changed your hosting package - you're in the right direction. But we would still love to get to the bottom of this.
Make sure your new hosting plan supports .htaccess.

You can also attach your WonderCMS files in a ZIP here, if you've made any changes to the files.

Hope we get to fix your problem as soon as possible. :)

Re: Absolute vs Relative Paths

Posted: Sat Mar 18, 2017 3:26 am
by wiz
Alternatively, try out the old .htaccess, might just do the trick.

Code: Select all

Options -Indexes
ServerSignature Off
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA,L]
RewriteRule database.js - [F]

Re: Absolute vs Relative Paths

Posted: Sat Mar 18, 2017 8:40 am
by rnd1530
Solved! with my old .htaccess :-) now works like charm, time to play.

Code: Select all

#RedirectMatch 403 ^.*/files/
ErrorDocument 403  
RewriteEngine on
Options -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1#%{REQUEST_URI} ([^#]*)#(.*)\1$
RewriteRule ^([^\.]+)$ %2?page=$1 [QSA,L]
RewriteCond %{THE_REQUEST} password($|\ |\?) [NC]
RewriteRule .* - [F]

#Disable Hot-linking
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://domain.com/.*$ [NC] [OR]
RewriteCond %{HTTP_REFERER} !^http://www.domanin.com/.*$ [NC] [OR]
RewriteRule .*\.(gif|GIF|jpg|JPG|bmp|BMP|wav|mp3|wmv|avi|mpeg|pdf)$ - [F]

Re: [SOLVED] Absolute vs Relative Paths

Posted: Sat Mar 18, 2017 12:51 pm
by wiz
Topic marked as solved - thanks rnd.

For future reference, mind answering which .htaccess worked for you?
1. The one you posted last?
2. The one I posted?

Re: [SOLVED] Absolute vs Relative Paths

Posted: Sat Mar 18, 2017 2:06 pm
by rnd1530
My version.