Results 1 to 5 of 5
  1. #1

    apache rewrite help

    I need a simple string replacement but couldn't make it work:

    I want
    ~~domain.com/string1/string2/id/RANDOMSTRING/

    to look like
    ~~domain.com/request/RANDOMSTRING/

    so basically "string1/string2/id" = "request"

    rewrite base is /

    please help!

    thanks a lot!

  2. #2
    Ok I found the reason it was not working: apache always add path info postfix so when it's supposed to be ~~domain.com/string1/string2/id/RANDOMSTRING/, it became ~~domain.com/string1/string2/id/RANDOMSTRING//RANDOMSTRING/

    Any idea?

  3. #3
    Join Date
    Apr 2009
    Posts
    211
    RewriteRule ^string1/string2/id/RANDOMSTRING /request/RANDOMSTRING$1 [L,QSA]
    █▌KVM-based SSD VPS
    ▌Unmetered Dedicated Servers
    ▌Colocation at 100 Delawanna Ave, Clifton, NJ

  4. #4
    thank you, but it doesn't work.

    domain.com/request/RANDOMSTRING/ is what I'll be using in browser and domain.com/string1/string2/id/RANDOMSTRING/ is where the url actual is. Also, "RANDOMSTRING" changes without pattern. So I need to replace /string1/string2/id/ with /request/ but need to keep "RANDOMSTRING" as it is.

    I currently have
    RewriteRule ^/request/(.*)/$ /string1/string2/id/$1/

    but in rewrite log, I saw apache added one more "RANDOMSTRING", so it tries to point at
    /string1/string2/id/RANDOMSTRING//RANDOMSTRING/

  5. #5
    Join Date
    Apr 2009
    Posts
    211
    RewriteRule ^request/(.*)/$ /string1/string2/id/$1/ [L,QSA] should work.

    You don't have to add anything at the end of the line.

    What's your version of apache?
    █▌KVM-based SSD VPS
    ▌Unmetered Dedicated Servers
    ▌Colocation at 100 Delawanna Ave, Clifton, NJ

Similar Threads

  1. Help w/ Apache Rewrite Rule
    By C4talyst in forum Programming Discussion
    Replies: 1
    Last Post: 11-22-2009, 07:53 PM
  2. Apache Rewrite
    By ans_steve in forum Programming Discussion
    Replies: 4
    Last Post: 12-26-2008, 10:43 AM
  3. apache rewrite ==> lighttpd rewrite HELP
    By moonswamp in forum Hosting Security and Technology
    Replies: 0
    Last Post: 07-24-2008, 07:59 PM
  4. apache rewrite ==> lighttpd rewrite HELP
    By Woooo in forum Hosting Security and Technology
    Replies: 9
    Last Post: 06-24-2008, 01:07 PM
  5. Apache ReWrite Help
    By mainarea in forum Programming Discussion
    Replies: 0
    Last Post: 06-17-2003, 02:59 PM

Posting Permissions

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