Mod ReWrite, Multipul Rules / Url Friendly

Discussion in 'Apache' started by designdev, May 1, 2009.

  1. #1
    Hi Everyone.

    I'm looking to use Mod ReWrite to generate URL Friendly paths/links on more than one file. for example.

    File 1). Index.php

    my main page displays listings of games.. 25 per page. Using a combination of the following i can manipulate the output of the results

    http://www.yourdomain.com/index.php?page=1
    PHP:
    http://www.yourdomain.com/index.php?cat=mmorpg
    PHP:
    http://www.yourdomain.com/index.php?cat=mmorpg&page=1
    PHP:
    If the "cat" value is not provided then the script will load all the listings regardless of category, but if the value is provided then it will filter them. In regards to the "page" value if no value is provided then the value defalts to "1" for page 1.

    So its important when using the Mod Rewrite that both varibles dont need to be provided.

    What i want as an output is

    http://www.yourdomain.com/1.php
    PHP:
    http://www.yourdomain.com/mmorpg/
    PHP:
    http://www.yourdomain.com/mmorpg/1.php
    PHP:

    What i am using for this to work is

    
    Options +FollowSymLinks
    RewriteEngine on
    
    RewriteRule ^(.+)/$ index.php?category=$1 
    RewriteRule ^(.+)/([0-9]+).php$ index.php?category=$1&page=$2 
    RewriteRule ^([0-9]+).php$ index.php?page=$1 
    
    PHP:

    However this seems to conflict when i want to use a true path that actually exisits for example

    http://www.yourdomain/admin
    PHP:
    instead i have to make sure i actually use the following, or it thinks "admin" is another possible category.

    http://www.yourdomain.com/admin/index.php
    PHP:




    File 2). details.php

    this file is used to display more information on each listing, by using the following

    http://www.yourdomain.com/details.php?id=1234
    PHP:
    what i would like instead is something like

    http://www.yourdomain.com/details-1234.php
    PHP:

    Any help on this would be very greatfull.
     
    designdev, May 1, 2009 IP
  2. Lpe04

    Lpe04 Peon

    Messages:
    579
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    you could add
    RewriteCond %{REQUEST_URI} !admin

    before your rewrite rules.
     
    Lpe04, May 4, 2009 IP