SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2008
    0 Post(s)
    0 Thread(s)

    Multiple rewriterules

    I've been playing with this for the last 2 hours with no success! Really hoping sitepoint members can help!

    As one normally does, we have rewrite running fine:
    RewriteEngine on
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1
    However, what I want to do as well, is when a particular script is accessed, to rewrite it back to the rewritten format above.

    For example:
    RewriteEngine on
    RewriteRule ^/somefolder/somescript.php(.*)$ index.php/$1 [L]
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1
    So if somefolder/somescript.php exists, translate the arguments to index.php like the other statement does. However, this doesn't seem to work.. Can anyone tell me what I'm doing wrong.. thank you.

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    20 Post(s)
    3 Thread(s)

    First, WELCOME to SitePoint's Apache Forum.

    Okay, back to WHAT rewritten format? No matter, what it looks like you're trying to do is to capture a query string with a RewriteRule. Since that cannot be done, you've got a problem. The answer is to capture the query string with a Rewrite Cond examining the %{QUERY_STRING} variable.

    Finally, even that is not necessary as the QSA (Query String Appended) flag is designed to do that for you (if you create a new query string) - otherwise, it gets sent to the redirection script naturally.

    Since you're not using query strings, however, you should take a look at the Options -MultiViews setting as most servers are set to NOT let you use a filename in place of a directory in a URI path.


    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Posting Permissions

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