This is my links in website:
mywebsite.com/index.php?id_1=main&id_2=kontakt
mywebsite.com/index.php?id_1=main&id_2=onama

How to remove from url that be like this
mywebsite.com/index.php/onama
mywebsite.com/index.php/kontakt

This is my index.php and in template pocetna.php

                <li><a href="index.php?id_1=main&id_2=kontakt">КОНТАКТ</a></li>
                <li><a href="index.php?id_1=main&id_2=onama">О НАМА</a></li>
<?php
session_start();
require_once("configuration.php");
require_once("functions.php");
require_once("session_load.php");
//require_once("connection.php");
$url_id = get_url_value();




// ucitavanje pocetne strane, homepage
if (($url_id['grupa'] == "0") and ($url_id['stranica'] == "0")){
        include_once ("includes/pocetna.php"); 
    }


// ucitavanje formi za logovanje i registraciju profesora i admina skola
if ($url_id['grupa'] == "form"){
        // ucitavanje zajednickog headera za forme za logovanje i registrovanje
        include_once ("includes/form_login_register_header.php");
        if ($url_id['stranica'] == "login_profesor"){
                include_once ("includes/form_login_profesor.php");
            }
        if ($url_id['stranica'] == "login_skola"){
                include_once ("includes/form_login_skola.php");
            }
        if ($url_id['stranica'] == "register_profesor"){
                include_once ("includes/form_register_profesor.php");
            }
        if ($url_id['stranica'] == "register_skola"){
                include_once ("includes/form_register_skola.php");
            }
        // ucitavanje zajednickog footera za forme za logovanje i registrovanje
        include_once ("includes/form_login_register_footer.php");
    }



// stranice o nama kontakt i portfolio

if ($url_id['grupa'] == "main"){
    include_once ("mainpage/main_header.php");  // header sa index strane sa prijavom
    if ($url_id['stranica'] == "kontakt"){
                include_once ("mainpage/kontakt.php");
            }
            if ($url_id['stranica'] == "onama"){
                include_once ("mainpage/onama.php");
                include_once ("mainpage/main_footer.php"); // footer sa index strane veliki
            }

            if ($url_id['stranica'] == "portfolio"){
                include_once ("mainpage/portfolio.php");
                include_once ("mainpage/main_footer.php"); // footer sa index strane veliki
            }
    include_once ("includes/form_login_register_footer.php");

    }




// stranice vezane za podatke koje modifikuje admin skole
if ($url_id['grupa'] == "skola"){
        // ucitavanje zajednickog headera za strane gde je ulogovan admin skole
        include_once ("");
        if ($url_id['stranica'] == "podaci"){
                include_once ("");
            }
        if ($url_id['stranica'] == "nastavnici_spisak"){
                include_once ("");
            }
        if ($url_id['stranica'] == "nastavnici_dodaj"){
                include_once ("");
            }
        if ($url_id['stranica'] == "nastavnici_portfolio"){
                include_once ("");
            }
        if ($url_id['stranica'] == "ucenici_spisak"){
                include_once ("");
            }
        if ($url_id['stranica'] == "ucenici_dodaj"){
                include_once ("");
            }
        if ($url_id['stranica'] == "ucenici_obrisi"){
                include_once ("");
            }
        if ($url_id['stranica'] == "ucenici_portfolio"){
                include_once ("");
            }
        // ucitavanje zajednickog footera za strane gde je ulogovan admin skole
        include_once ("");
    }


// ucitavanje strana za obradu formi
if ($url_id['grupa'] == "submitform"){
        if ($url_id['stranica'] == "login_profesor"){
                include_once ("formsubmit/submitform_login_profesor.php");
            }
        if ($url_id['stranica'] == "login_skola"){
                include_once ("formsubmit/submitform_login_skola.php");
            }
        if ($url_id['stranica'] == "register_profesor"){
                include_once ("formsubmit/submitform_register_profesor.php");
            }
        if ($url_id['stranica'] == "register_skola"){
                include_once ("formsubmit/submitform_register_skola.php");
            }
    }




//mysql_close($connection);
?>

If you would like to use friendlier URLs, you can create and configure the .htaccess file and create URL rewrite rules to do this.

you can create rules so that your URL looks like this...

mywebsite.com/index/kontakt to map to mywebsite.com/index.php?id_1=main&id_2=kontakt

Are you familiar with .htaccess and how to work with regex?

I know .htacces but i dont know how to do that.

Thanks diafol!!

You could try using these .htaccess lines:

RewriteEngine on

Options -Indexes

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

Everything will be redirected to index.php. In index.php you can then use PHP to parse the url and take the required actions. E.g. by using $_SERVER['HTTP_REFERER'] to read the uri.

Not work with this RewriteEngine on
Options -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

you see my code of index.php but i not know .htaccess

How to $_SERVER['HTTP_REFERER'] use in my index.php

You create the .htaccess file yourself, in your root directory. Then you use PHP to parse the URL. Example with the .htaccess file I provided:

<?php
$uri = $_SERVER['REQUEST_URI'];
$explode = explode('/', $uri);

// Let's see what's in the uri:
echo '<pre>'; print_r($explode); echo '</pre>';

// Let's say your uri looked like /id/1, then:
$id = $explode[1];
// Because $explode would look like this: array([0] => 'id', [1] => 1)

(Sorry, I mentioned $_SERVER['HTTP_REFERER'] before, but I actually meant $_SERVER['REQUEST_URI']).

One effective method using $_SERVER['REQUEST_URI'] with optional .htaccess support is the method found on frameworks like CI, Symfony, Kohana, and Laravel. These frameworks pretty much rely on the REQUES_URI for routing page requests.

Example of a router ( the most basic, without involving a json file or xml file).

Let say, we have two pages index.php and pageone.php. Pageone.php is the destination page provided by the link..

filename: index.php

<a href="pageone.php/Learning%20PHP%20MySQL%20PHP/Robin%20Nixon/oreily%20Media/2013/">View this Book</a>

filename: pageone.php

## we pick up the request uri
$book_data = $_SERVER['REQUEST_URI'];

## we get rid of front and end forward slashes 
$book_data = trim( $book_data, "/" );

## we use PHP list function
list($scriptName,$title,$author,$publisher,$year) = explode('/',$book_data);

## you must strictly set your conditions here, otherwise this is not going to work. e.g. conditions must be similar to form processor.

## echo the parse book data.
echo 'This is the pagename or scriptname : '. basename($scriptName).'<br/>'
echo 'Title : '. trim($title).'<br/>';
echo 'Author : '. trim($author).'<br/>';
echo 'Publisher : '. trim($publisher).'<br/>';
echo 'Year : '. trim($year) .'<br/>';

Test the abov sample codes, it should work ( i think... never tested it..).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.