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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.