Jump to content

PHP URL's + MOR REWRITE - BASIC PROBLEM


crashmaster

Recommended Posts

Hi there !

 

I am beginner with mod_rewrite, but quite advanced in PHP. But I still cann't understand 1 thing in mod_rewrite.

 

I programming web and need use "nice url's" , so I have to start using nice url's.

 

My problem is:

 

I have main php - its INDEX.PHP/

Content in this file has this PHP script for content manipulation:

 

<?
                               $page = strtolower($_GET['page']);
                                if (ereg('[a-z0-9]',$page) ) {
                                    if (file_exists('pages/'.$page.'.php')) {
                                        include('pages/'.$page.'.php');
                                    } else {
                                        include('pages/main.php');
                                    }
                                } else {
                                        include('pages/main.php');
                                }
?>

 

 

In my work I have to use special urls. But I have problem with a folders.

I need special rule:

  1) if link starts with word "ad", there should be several rules:

            a)link: localhost/ad/{category}/{section}/{ad_id}/{header_of_ad(this part is for SEO,not important)}

            request for localhost/index.php should be: index.php?page=ad&cat={category}&sec={section}&ad_id={ad_id}

 

            b) if link just: localhost/ad/{category}/

            request for localhost/index.php should be: index.php?page=ad&cat={category}

 

  2) If the link doesn't start with ad, it should be:

            localhost/{something}/  => localhost/index.php?page={something}

 

 

That's all I need, can anybody help me ?)

 

     

Link to comment
https://forums.phpfreaks.com/topic/123164-php-urls-mor-rewrite-basic-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.