user2506760
user2506760

Reputation: 87

url rewriting does not return $_GET

I've set some rules for url rewritte on my website.

Actually I'm on localhost

I've set this in .htaccess

php_flag output_buffering on
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^p/([^/]*)\.html$ /?p=$1 [L]

Actualy url rewrite does works (I adde a base href in the header for css, js, and lib php

The trouble I met is that it does not return the $_GET param.

I've written a function for including the pages in the main frame of my document, so we have this

function includePage(){
    if(isset($_GET['p'])){
        $page = mysql_real_escape_string($_GET['p']);
        if(file_exists('p/'.$page.'.phtml')){
            include('p/'.$page.'.phtml');
        }else{
            include('p/404.phtml');
        }
    }else{
        include('p/accueil.phtml');
    }
}

Actualy it does not works it returns to me everytime the else condition.

I've tried to do a var_dump($_GET['p']) it returns to me an undefined var

the url looks like this :

index.php/p/realisations so the param $_GET['p'] should be equal to 'realisations' in that case, actualy it does not work.

I do not know where I'm wrong. I've done some reasearch with no success.

anykind of help will be much appreciated.

Upvotes: 2

Views: 337

Answers (1)

anubhava
anubhava

Reputation: 785166

Try this rule:

RewriteEngine On
RewriteRule ^index\.php/p/([^/.]+)(\.html)?$ ?p=$1 [L,NC,QSA]

Upvotes: 1

Related Questions