SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Sep 2008
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple mod-rewrite

    Can mod-rewrite do this?

    All urls pointing to 'domain.com/1-xxx' to use the page1.php page

    All urls pointing to 'domain.com/1-xxx/xxx-xxx' to use the page2.php

    All x values will relate to a number.

    Thanks.

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

    Yes.





    Aw, this is too simple not to answer with code!

    Code:
    RewriteEngine on
    RewriteRule ^1-\d{3}$ page1.php [L]
    RewriteRule ^1-\d{3}/\d{3}-\d{3}$ page2.php [L]
    I'm sure that will fail any test except for those replacing each x with a digit. Are you really throwing away the values contained in the digits?

    Oh, well, I'll leave it to you to alter the number of digits required each time AND give a better specification if you need the values contained in the digits.

    Regards,

    DK
    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


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
  •