Mod_rewrite with question marks

Posted on 2008-11-14
Last Modified: 2012-05-05
I'd like to redirect from:



Question by:liz2008
    LVL 27

    Expert Comment

    So you'd like to check the QueryString:
    RewriteEngine on
    RewriteCond %{QUERY_STRING} =sid=faculty
    RewriteRule ^faculty/faculty\.php$ /faculty/? [R=301,L]

    Open in new window


    Author Comment

    That works great! thank you.  
    I have many more that I need to redirect, and I have not figured out the pattern.

    For example:

    1. faculty/faculty.php?sid=faculty               to                 faculty/

    2. faculty/faculty_core.php?sid=faculty     to              faculty/scientific_cores.html

    3. faculty/faculty_laboratories.php?sid=faculty    to               faculty/labs_centers.html

    4. faculty/faculty_resources.php?sid=faculty     to     faculty/biology_resources.html

    thank you!
    LVL 27

    Accepted Solution

    Since the filename differs between "input" and "output", you'll need "hard-coded" rules, i.e. they cannot be generic
    RewriteEngine on
    RewriteCond %{QUERY_STRING} =sid=faculty
    RewriteRule ^faculty/faculty\.php$ /faculty/? [R=301,L]
    RewriteCond %{QUERY_STRING} =sid=faculty
    RewriteRule ^faculty/faculty_core\.php$ /faculty/scientific_cores.html? [R=301,L]
    RewriteCond %{QUERY_STRING} =sid=faculty
    RewriteRule ^faculty/faculty_laboratories\.php$ /faculty/labs_centers.html? [R=301,L]
    RewriteCond %{QUERY_STRING} =sid=faculty
    RewriteRule ^faculty/faculty_resources\.php$ /faculty/biology_resources.html? [R=301,L]

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Suggested Solutions

    Preface There are many applications where some computing systems need have their system clocks running synchronized within a small margin and eventually need to be in sync with the global time. There are different solutions for this, i.e. the W3…
    If, like me, you have a lot of Dell servers in the estate you manage this article should save you a little time. When attempting to login to iDrac on any server I would be presented with two errors. The first reads "Do you want to run this applicati…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    760 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

    7 Experts available now in Live!

    Get 1:1 Help Now