SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Nov 2008
    Location
    UK
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to extract a subdirectory with htaccess rewrite

    For www.domain.com/area/north

    I can use:
    RewriteRule area\/([0-9a-zA-Z_\&\-\ \.\/]+)$ home.php?areasearch=$1 [QSA,L]
    to grab 'north' and pass it as a parameter to my home page

    But now my url is more like:

    http://www.domain.com/area/north/hom...ntshow=listing.....

    I can't work out how to get at the 'north' bit without all the stuff afterwards

    something like:
    RewriteRule area\/([0-9a-zA-Z_\&\-\ \.\/]+)$\/([0-9a-zA-Z_\&\-\ \.\/]+)$ home.php?areasearch=$1 [QSA,L]
    ??

    I know it should be simple, but I just can't get it to work!
    Any help appreciated!

  2. #2
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    Hi,Your requirements are a little unclear.Do you want www.domain.com/home.php?areasearch=north with www.domain.com/area/north
    Quote Originally Posted by treacle0996 View Post
    For www.domain.com/area/northI can use:RewriteRule area\/([0-9a-zA-Z_\&\-\ \.\/]+)$ home.php?areasearch=$1 [QSA,L]to grab 'north' and pass it as a parameter to my home pageBut now my url is more like:http://www.domain.com/area/north/hom...ntshow=listing.....I can't work out how to get at the 'north' bit without all the stuff afterwardssomething like:RewriteRule area\/([0-9a-zA-Z_\&\-\ \.\/]+)$\/([0-9a-zA-Z_\&\-\ \.\/]+)$ home.php?areasearch=$1 [QSA,L]??I know it should be simple, but I just can't get it to work!Any help appreciated!
    ictus==""

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2008
    Location
    UK
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2008
    Location
    UK
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, been looking at this again - I think my logic was all back to front

    I can just extract the bit I need from $_SERVER['REQUEST_URI'] and use that.

  5. #5
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    2 Thread(s)
    Good glad to hear that you found something that suits your needs.
    ictus==""


Bookmarks

Posting Permissions

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