SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    Mars
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    index.php?a=1&b=2 to index/a-1/b-2

    hi,

    I have this link

    www.domain.com/myfolder/index.php?a=1&b=2

    when the user clicks or types this link, I want it to be dispalyed on the browser like the following:
    www.domain.com/myfolder/index/a-1/b-2

    Is this possible? and how can I do it

  2. #2
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    RewriteEngine On
    RewriteRule ^index/a-([0-9]+)/b-([0-9]+)/?$ index.php?a=$1&b=$2 [L]
    That should do the trick, place it in your myfolder directory in a .htaccess file

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    Mars
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It worked but the user is not being redirected to the new firenly URL

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

    Dean forgot to change the [L] to [R=301,L] - an easy thing to overlook .

    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

  5. #5
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    Mars
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried that but the URL didnt change, still in the old format.

    any more help?

  6. #6
    SitePoint Wizard Dean C's Avatar
    Join Date
    Mar 2003
    Location
    England, UK
    Posts
    2,906
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can't magically change one link into the other without redirecting The R=301 flag should fix this issue. Are you sure you changed it exactly as David said? Also is the .htaccess file in your myfolder dir?

  7. #7
    SitePoint Enthusiast
    Join Date
    Dec 2003
    Location
    Mars
    Posts
    89
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, I changed it exactly as David said, and the .htaccess file is in myfolder dir.

    but when I type the old URL, it doesnt change to the new one!

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

    So long as you haven't thrown us a curve (e.g., CAPITAL letters, etc), Dean's code WILL work as advertised. That leaves us with the likelihood that there is a setup problem.

    Would you please give the mod_rewrite test (datakoncepts.com/seo) a try and report whether you get the HTML or PHP script served to you from your myfolder directory. That should verify that you have your mod_rewrite setup correctly. Then we'll have you post your .htaccess file (from the myfolder directory) AND confirm that you uploaded it as a TEXT file rather than BINARY.

    From there, we can delve into this a bit further and correct the problem wherever it lies.

    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

  9. #9
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From what I see, that's not the code he wants.

    but when I type the old URL, it doesnt change to the new one
    That's not the function of mod-rewrite. You'r supposed to stop using the old format and start using the new format. This means you'll have to edit the links on your pages.
    Mike
    It's not who I am underneath, but what I do that defines me.


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
  •