.htaccess url cleanup needs code fix...

21 views
Skip to first unread message

Robert Chatman

unread,
Jun 20, 2011, 3:50:41 PM6/20/11
to rainfr...@googlegroups.com
Hello!

Thank you for this miraculous framework! I have gotten my head (pretty much) wrapped around the features and so i started work on my app. The good news is things went smooth until i did my mod_rewrite cleanup. 

I know you are trying to make the project open sourced, and have already followed the project on github, so if you would rather i do the fix and submit it that is fine, but i wanted to make sure that my fix is in line with where you want the projet to go. 

Either way, in _set_route, route may be null and that leads to some oddities.

how about if it is null check the QUERY_STRING or REQUEST_URL? those seem to hold on to the parameters. :

.htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/%{PATH_INFO}?$1 [QSA,L] </IfModule>

// and then down in the router, something lie the following.
Router.php
private function _set_route()
{
$route = isset( $_SERVER["PATH_INFO"] ) ? substr($_SERVER["PATH_INFO"],1) : null;
if (empty($route) && !empty($_SERVER['QUERY_STRING']))
{
$route = explode('&', $_SERVER['QUERY_STRING'], 2);
$route = $route[0];
}
else if ($route == null)
return self::$route = '';
$config_route = self::$config_route;
foreach( $config_route as $key => $value )
{
$key = str_replace( ':any', '.+', $key );
$key = str_replace( ':num', '[0-9]+', $key );
if (preg_match('#^'.$key.'$#', $route ) )
return self::$route = preg_replace( '#^'.$key.'$#', $value, $route );
}
return self::$route = $route;
}

megabr

unread,
Jul 4, 2011, 3:07:24 PM7/4/11
to rainframework
Hi, I need SEO url, on my app, your fix is working fine?

regards

Robert Chatman

unread,
Jul 5, 2011, 3:05:54 PM7/5/11
to rainfr...@googlegroups.com
It works pretty well, but you may need to work with it a bit. 

here is the function as i am using it currently:

private function _set_route()
{
$route = explode('&', $_SERVER['QUERY_STRING'], 2);
$route = $route[0];
Reply all
Reply to author
Forward
0 new messages