SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I want to convert my url www.mydomain.com/menu.php?id=1 to www.mydomain.com/menu./1

    Hello friends.!!
    I am new at .htaccess
    i have a query
    I want to convert my url www.mydomain.com/menu.php?id=1
    to www.mydomain.com/menu./1
    Please help with detail procedure..

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Hi jun$,

    You want to take a look at mod_rewrite and specifically around RewriteRule, here is a site that can give you a quick introduction
    http://datakoncepts.com/seo and it has has Code Generator

    Or you can read all of this off the Apache Site
    http://httpd.apache.org/docs/current...d_rewrite.html
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  3. #3
    SitePoint Member
    Join Date
    Oct 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanx

    Hi cpradio,
    Thanks for your info.
    I will check out this.

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jun$ View Post
    Hi cpradio,
    Thanks for your info.
    I will check out this.
    Please post any follow up questions if you don't find what you are looking for or it doesn't make sense.
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

  5. #5
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,644
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Thanks cp!

    jun$,

    That's just too easy, however, as my tutorial states, it's YOUR job to link to the new format and mod_rewrite's job to redirect back to something which Apache can serve (in other words, your "convert ... to" is the wrong direction). Yes, you can redirect to the new format then back to the original but that takes some slight of hand and, if you're asking this question, you're not quite ready for that yet!

    To convert TO menu.php?id=1 from menu./1 (is that dot supposed to be there before the /???):

    Code:
    # .htaccess in domain.com's DocumentRoot
    
    RewriteEngine on
    RewriteRule ^menu\./([0-9]+)$ menu.php?id=$1 [L]
    This regex simply requires menu./ before some digits (and nothing else), captures the digits and redirects (without being seen - that would require the R=301 flag) to menu.php?id={the digits}.

    If you have any questions on this or the tutorial, you know where to find me (or PM).

    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

  6. #6
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,069
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Just to add on, (if that dot shouldn't be there )
    Code:
    # .htaccess in domain.com's DocumentRoot
    
    RewriteEngine on
    RewriteRule ^menu/([0-9]+)$ menu.php?id=$1 [L]
    Be sure to congratulate Patche on earning July's Member of the Month
    Go ahead and blame me, I still won't lose any sleep over it
    My Blog | My Technical Notes

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

    Amen (that was about the strangest thing I've seen in a while ... but, if part of this member's specification rather than a typo, it did have to be dealt with.

    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
  •