[SOLVED] Absolute vs Relative Paths

rnd1530
Posts: 7
Joined: Wed Mar 15, 2017 10:14 am

[SOLVED] Absolute vs Relative Paths

Post 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...
User avatar
wiz
Posts: 749
Joined: Sat Oct 30, 2010 12:23 am

Re: Absolute vs Relative Paths

Post 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?
rnd1530
Posts: 7
Joined: Wed Mar 15, 2017 10:14 am

Re: Absolute vs Relative Paths

Post 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.
User avatar
wiz
Posts: 749
Joined: Sat Oct 30, 2010 12:23 am

Re: Absolute vs Relative Paths

Post 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?
rnd1530
Posts: 7
Joined: Wed Mar 15, 2017 10:14 am

Re: Absolute vs Relative Paths

Post 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 :)
User avatar
wiz
Posts: 749
Joined: Sat Oct 30, 2010 12:23 am

Re: Absolute vs Relative Paths

Post 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. :)
User avatar
wiz
Posts: 749
Joined: Sat Oct 30, 2010 12:23 am

Re: Absolute vs Relative Paths

Post 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]
rnd1530
Posts: 7
Joined: Wed Mar 15, 2017 10:14 am

Re: Absolute vs Relative Paths

Post 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]
User avatar
wiz
Posts: 749
Joined: Sat Oct 30, 2010 12:23 am

Re: [SOLVED] Absolute vs Relative Paths

Post 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?
rnd1530
Posts: 7
Joined: Wed Mar 15, 2017 10:14 am

Re: [SOLVED] Absolute vs Relative Paths

Post by rnd1530 »

My version.
Post Reply