Page 1 of 1

$_SERVER['REQUEST_URI'] and mod_rewrite

Posted: Thu Jan 24, 2008 4:18 am
by ynwa
Hi
I have an .htaccess file

Code: Select all

RewriteEngine on 
 
Options +FollowSymlinks
 
RewriteBase /
 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
 
RewriteRule ^(.*)$ /index.php [L,QSA]
when I'm trying to get pahe http://cms/guestbook/index/

I have such result

Code: Select all

$url = explode ('/', $_SERVER['REQUEST_URI']);
echo '<pre>';
print_r($url);
echo '</pre>';

Code: Select all

Array
(
    [0] => 
    [1] => guestbook
    [2] => index
    [3] => 
)
Why do I have this empty elements, i think that is because folders? What I have to do to delete this elements?

Re: $_SERVER['REQUEST_URI'] and mod_rewrite

Posted: Thu Jan 24, 2008 4:32 am
by Christopher
The string has slashes at the beginning and end.

Re: $_SERVER['REQUEST_URI'] and mod_rewrite

Posted: Thu Jan 24, 2008 4:39 am
by ynwa
And how can I delete this slashes, maybe I have wrong rule at mode rewrite? In future I want to use frontController, and I have to parse $_SERVER['REQUEST_URI'] and I think that first element is action and second - controller, but this empty elements, I don't like it :\

Re: $_SERVER['REQUEST_URI'] and mod_rewrite

Posted: Thu Jan 24, 2008 8:10 am
by Zoxive

Code: Select all

$NoBeginningOrEndingSlashes = trim($Var.'/');