Mod rewrite conditional

Posted on 2006-05-05
Last Modified: 2008-02-01

I'm trying out some stuff with mod rewrite and only have partial success.  I'll give you the problem and show you what I've got and hopefully we can all figure out how to make this work for me = )

I have the site
When going to different areas of the page I am using

What I wanted to do is turn that into and when the second one is called

Make sense?

RewriteCond   %{REQUEST_FILENAME} !-f
RewriteCond   %{REQUEST_FILENAME} !-d
RewriteRule   ^(.*) subsite.php\?Site=$1 [QSA,L]

That gets me the first one so I try to tweak that out a bit to:
RewriteRule ^(.*)-([A-Za-z_\ -]+)\/ subsite.php\?Site=$1&Ex=$2 [QSA,L]

Now I'm running into problems.  I'm sure it will be obvious to those of you with more skills/knowledge of URL rewriting but that's not me = /

Thank you very much for any help you can assist with this.
Question by:gijew
    1 Comment
    LVL 5

    Accepted Solution

    i would probably do it like this.

    RewriteRule ^/([0-9a-zA-Z_]+) subsite.php?Site=$1 [L]
    RewriteRule ^/([0-9a-zA-Z_]+)/([0-9a-zA-Z_]+) subsite.php?Site=$1&Ex=$2 [L]

    hope this helps.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now