简体   繁体   English

网址重写未返回$ _GET

[英]url rewriting does not return $_GET

I've set some rules for url rewritte on my website. 我已经在网站上为url重写设置了一些规则。

Actually I'm on localhost 其实我在本地主机上

I've set this in .htaccess 我已经在.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 实际上,URL重写确实可以工作(我在css,js和lib php的标头中添加了基本href

The trouble I met is that it does not return the $_GET param. 我遇到的麻烦是它不会返回$ _GET参数。

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 我试图做一个var_dump($_GET['p'])它返回给我一个未定义的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. index.php / p / realisations,因此在这种情况下,参数$ _GET ['p']应该等于“ realisations”,实际上它不起作用。

I do not know where I'm wrong. 我不知道我哪里错了。 I've done some reasearch with no success. 我做了一些研究但没有成功。

anykind of help will be much appreciated. 任何帮助将不胜感激。

Try this rule: 尝试以下规则:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM