Home Rewrite url with 2 or more params
Reply: 0

Rewrite url with 2 or more params

user1443 Published in March 21, 2018, 8:20 pm

I asked a question like this before but since i still can't find an answer to this i'll ask it again :-s.

I'm using this very basic 'templating' script:

require_once 'core/init.php';

    header('Location: home');

$basePath = dirname(__FILE__) . '/';
$viewPath = $basePath . 'view/';

$view = scandir($viewPath);

foreach($view as $file)     
    if (!is_dir($viewPath . $file))
        $pages[] = substr($file, 0, strpos($file, '.'));


if(in_array($_GET['page'], $pages)){
    include($viewPath . $_GET['page'] . '.php');
} else{
    include($basePath . '404.php');

and i'm rewriting my url from /base/index.php?page=somepage to /base/somepage(somepage is a .php file in my template folder) using this htaccess file

RewriteEngine On

RewriteBase /base/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?page=$1 [L,QSA]

With 1 parameter it works just fine but my problem is that i don't know how to rewrite a second param /base/profile?user=username (with no htaccess file this would have look like this /base/index.php?page=profile?user=username) and i want it to look like this /base/profile/username.

I hope that this question is understandable :-s

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.394792 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO