www.webdeveloper.com
Results 1 to 2 of 2

Thread: Looking for help with 2-tier clean URL's using .htaccess

  1. #1
    Join Date
    Mar 2006
    Posts
    38

    Looking for help with 2-tier clean URL's using .htaccess

    I am working on a site which will have two levels the URL reaches

    My objective is to have clean URL's like this...

    http://domain.com/username/dosomething

    My ugly URL's currently look like this...

    http://domain.com/index.php?page=use...nd=dosomething

    Code:
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1&command=$2
    RewriteRule ^([a-zA-Z0-9]+)/$1/$2 index.php?page=$1&command=$2

  2. #2
    Join Date
    Oct 2010
    Location
    Ohio
    Posts
    233
    This is my .htaccess to achieve what you are talking about. It doesn't redirect if requesting an existing file (say an image, or what have you)

    Code:
    RewriteEngine ON
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule (.+) $1 [L]
    
    RewriteRule ^([^/]+)/([^/]+)/(.*)$ index.php?resource=$1&page=$2&qry=$3 [L]
    RewriteRule ^([^/]+)/([^/]+)/?$ index.php?resource=$1&page=$2 [L]
    RewriteRule ^([^/]+)/?$ index.php?resource=$1 [L]
    HTH

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles