Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
Pascal is on a distinguished road
 
Posts: 2
Join Date: Oct 2011
Unhappy .htaccess - URL re-writing. - 10-25-2011, 04:36 PM

Hello guys,

I'am having problems re-writing my proto-website URLs on distant server.

My configuration runs perfectly locally on WampServer with :

1° Following re-writing rules as part of the .htaccess file located at the root of my site:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule !\.(js|ico|gif|jpg|jpeg|png|css)$ index.php [NC,L]

2° Following function url($url) : (as part of a library folder)

function url($url) {
$controller = $url['controller'];
$action = $url['action'];
$parametres = '';
foreach ($url as $variable => $valeur) {

if ($variable != 'controller' && $variable != 'action')
$parametres .= "/" . $variable . "/" . $valeur;
}
return BaseUrl . '/' . $controller . '/' . $action . $parametres . '.html';
}

3° Following getParams function : (also part of the same library folder)

function getParams() {
$chaine = '';
if (isset($_SERVER['REQUEST_URI']))
$chaine = $_SERVER['REQUEST_URI'];
$pattern = dirname($_SERVER['PHP_SELF']);
if ($pattern == '/'

)$pattern = '';
$replacement = '';
$chaine = substr($chaine, strlen($pattern));
$pattern = '/\.(php|htm|html)$/';
$replacement = '';
$chaine = preg_replace($pattern, $replacement, $chaine);
$pattern = '/\//';
$parametres = preg_split($pattern, $chaine);
if (!isset($parametres[1]))
$parametres[1] = '';
if (!isset($parametres[2]))
$parametres[2] = '';
$params = array(
'controller' => $parametres[1],
'action' => $parametres[2],
);
for ($i = 4; $i < count($parametres); $i+=2) {
$params[$parametres[$i - 1]] = $parametres[$i];
}
return $params;
}

I also tried adding RewriteBase / but it did not change anything.

Any idea of what could be missing to make this work on distant server ?

Thks+regards,
Pascal.
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
purcellj's Avatar
Senior Member
purcellj is on a distinguished road
 
Posts: 159
Join Date: Aug 2010
Location: Bedford, Bedfordshire, England
Send a message via MSN to purcellj Send a message via Skype™ to purcellj
Default 10-25-2011, 05:29 PM

Sorry, I know you explained a lot but Im not entirely sure what you mean
Reply With Quote
(#3 (permalink))
Old
Junior Member
Pascal is on a distinguished road
 
Posts: 2
Join Date: Oct 2011
Unhappy 10-25-2011, 07:46 PM

Hello purcellj,

Thank you for your reply.

Functions describe in points 2 and 3 actually handle the URL re-writing but only work when triggered by the .htaccess file.
This work fine on local server but for a reason(s) that i'am trying to find out, not on distant server.
I'am sure this is a trifle thing but i just cannot put my finger on it.

Hope above explanations will help you to help me !

Regards,
Pascal.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com