#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Posts
    199
    Rep Power
    29

    Multi-Level clean url + php query string


    EDIT: The PHP half of this is solved. I need some help with the Mod_Rewrite portion. If a Mod feels this should be moved, please do so.


    I'm trying to use a multi-level query string based in a clean url.

    So say I have:

    www.domain.com/contact

    I want a second page under the contact page, such as:

    www.domain.com/contact/feedback

    I think I may have an issue with my mod_rewrite rule.

    Here's my mod_rewrite rule:

    Code:
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/?([^/]+)/?([^/]+)/?([^/]+)/? /index.php?p=$1&s=$2&t=$3 [L,QSA]
    Last edited by HDFilmMaker2112; March 8th, 2013 at 02:09 PM.
  2. #2
  3. Jealous Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,303
    Rep Power
    9400
    So /contact/feedback goes to
    Code:
    index.php?p=contact&s=feedback&t=
    Your Rule requires something in each of the three "directories". Try changing the second and third to use a * instead.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2006
    Posts
    199
    Rep Power
    29
    Solved. Just dealt with the problem via PHP, by using
    if($_GET['s']!='') and if($_GET['t']!='')

    PHP Code:
        if(isset($_GET['p'])){
        
    $URL=$_GET['p'];
            
    //if /home is in URL redirect back to base domain name
            
    if($URL=="home"){
            
    header("Location: /");
            }else{}
            
    //if 's' is set in the URL overwrite $URL with sub-page name
            
    if(isset($_GET['s']) && $_GET['s']!=''){
            
    $URL=$_GET['s'];
                
    //if 't' is set in the URL overwrite $URL with sub-sub-page name
                
    if(isset($_GET['t']) && $_GET['t']!=''){
                
    $URL=$_GET['t'];
                }else{}
            }else{}
        }
        else{
        
    $URL="home";
        } 
    Last edited by HDFilmMaker2112; March 8th, 2013 at 03:01 PM.

IMN logo majestic logo threadwatch logo seochat tools logo