Page 1 of 1

[SOLVED] .htaccess problems

Posted: Tue Apr 11, 2017 11:18 am
by madhatter
Installed WonderCMS on my 1and1 hosting - and bang :( cannot get the URL rewriting to work at all - no admin panel, no nothing.

File permissions all checked and I've played around with the .htaccess file even adding various rewrite base options but nothing. Any ideas at all as to what I'm doing wrong?

URL: http://testing.taffmedia.co.uk

htaccess content:

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /homepages/17/d539292587/htdocs/taffmedia/testing/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]

</IfModule>

Re: .htaccess problems

Posted: Wed Apr 12, 2017 7:45 am
by prakai.na
Same as me. On our system, We use 'AliasMatch' option to match URL to local directory (user's home directory), without modify 'DocumentRoot' option.

Code: Select all

AliasMatch ^/user/([a-zA-Z0-9\_\.]*)/?(.*) /home/user/$1/public_html/$2
I have modified 2 files to fix this problem.

index.php

Code: Select all

public static function url($location = '') {
        return 'http' . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']) . '/' . $location;
}
This function returns path based on URL not 'DocumentRoot'.

.htaccess

Code: Select all

Options -Indexes
ServerSignature Off
RewriteEngine on
RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
RewriteRule ^.*$ - [E=CWD:%2]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ %{ENV:CWD}index.php?page=$1 [QSA,L]
RewriteRule database.js - [F]
Using url_rewrite without knowing RewriteBase.
ref: http://www.zeilenwechsel.de/it/articles ... eBase.html

Re: .htaccess problems

Posted: Wed Apr 12, 2017 8:48 am
by madhatter
prakai.na you are a total star!

Thank you :) that's fixed and working perfect!!!! I've spent ages on this with no joy and then your fix sorts it in seconds.

Massive thank you. :D

Re: .htaccess problems

Posted: Wed Apr 12, 2017 8:59 am
by prakai.na
Your welcome. :D

Re: .htaccess problems

Posted: Thu Apr 13, 2017 6:33 pm
by wiz
Do you guys this solution would work for most WonderCMS users? As in an universal solution.

Aren't there any security downsides or downsides in general to using

Code: Select all

$_SERVER['SCRIPT_NAME']
?