SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: url rewrite without passing filename

  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    url rewrite without passing filename

    I have this rule:
    Code:
    RewriteRule ^.*/pr/?([^/]*)/?([^/]*)/?$ /product.php?products_id=$1&page=$2
    Is it possible to capture target file (file where link leads to) without including it into string passed to rewrite?
    String to rewrite I'm passing looks something like this:

    [dabljux3].site.com/cables-accessories/speaker-cables/audioquest/type-6-offcut/product/2393/1
    Please note: no filename passed.

    I tried (among others):
    Code:
    RewriteRule ^.*/product/?([^/]*)/?([^/]*)/?$ /%{REQUEST_FILENAME}?products_id=$1&page=$2
    cur it does not seem to work.

    Anyone can help?

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,314
    Mentioned
    15 Post(s)
    Tagged
    2 Thread(s)
    jeff,

    Rather than passing the original URI, use {THE_REQUEST}. Just have a play with it as it includes the method (POST/GET) as well as other information (besides the requested URI).
    [QUOTE=jeffz2008;4505397]I have this rule:
    Code:
    RewriteRule ^.*/pr/?([^/]*)/?([^/]*)/?$ /product.php?products_id=$1&page=$2
    Is that ? supposed to be the ? metacharacter (zero or one of the preceding character) OR the separation character to denote the query string (which can only be accessed by a RewriteCond looking at the {QUERY_STRING})? Okay, from your example, you're okay as it didn't have a query string.

    Regards,

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

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
  •