SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member lost_in_code's Avatar
    Join Date
    Jan 2004
    Location
    USA
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mod Re-Write Assistance Requested - Ideas / Conceptual Outputs?

    Hello.

    Can anyone help with a mod-rewrite idea below, hopefully this will provide enough information. I can write the software to put out most the information and change the parms, but I do have some limitations on the software end. So my hopes was to handle the output to the browser client and search engines using mod re-write.

    Code:
     
    #####################################################
    ### Main Category Output ###
    http://www.ourdomain.com/cgi-bin/awm.xpi/store.html?p_scn=a-great-category&p_cid=36
    to > http://www.ourdomain.com/a-great-category.html
    or > http://www.ourdomain.com/a-great-category_c36.html
    #####################################################
     
    #####################################################
    ### Main Category Output With Page Numbers ###
    http://www.ourdomain.com/cgi-bin/awm.xpi/store.html?p_scn=a-great-category&p_cid=36&page=2
    to > http://www.ourdomain.com/a-great-category-p2.html
    or > http://www.ourdomain.com/a-great-category-c36-p2.html
    #####################################################
     
    #####################################################
    ### Direct Product Output to Product Number & Category Ref ###
    http://www.ourdomain.com/cgi-bin/awm.xpi/products.html?p_scn=a-great-product-online&p_pid=1569&p_cid=36
    to > http://www.ourdomain.com/a-great-product-online.html
    or > http://www.ourdomain.com/a-great-product-online-p1569-c36.html
    #####################################################
     
    #####################################################
    ### Direct Product Layout to Product Number - No Category Ref ###
    http://www.ourdomain.com/cgi-bin/awm.xpi/products.html?p_scn=a-great-product-online&p_pid=1569
    to > http://www.ourdomain.com/a-great-product-online.html
    or > http://www.ourdomain.com/a-great-product-online-p1569.html
    #####################################################
    Now if anyone has a better idea of a output structure, I would love to hear it. I have some ideas. However; I'm not a mod re-write expert and not sure I'm doing this as efficient as someone else may be able to do. I just want to make it to be easier for the search engine to index the site as well as find anything in of our server log files for tracking.

    Thank you kindly for any help...

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

    The problem you're asking about is similar to the one I discuss in my signature's tutorial. Have you had a look there?

    No? (Grrr!) Let me summarize, then. Unless you can create a RewriteMap (you MUST have access to httpd.conf), you MUST use sufficient information in your URI to be able to redirect to a servable file, i.e., your "or" choices look like your best bet.

    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

  3. #3
    SitePoint Member lost_in_code's Avatar
    Join Date
    Jan 2004
    Location
    USA
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn View Post
    lic,

    The problem you're asking about is similar to the one I discuss in my signature's tutorial. Have you had a look there?

    No? (Grrr!) Let me summarize, then. Unless you can create a RewriteMap (you MUST have access to httpd.conf), you MUST use sufficient information in your URI to be able to redirect to a servable file, i.e., your "or" choices look like your best bet.

    Regards,

    DK
    Hello, I do have access to the httpd.conf on the root of the server, the only issue I have is, I'm not 100% sure how to formulate the mod re-write. Can you please assist with this at all? Thank you.
    Last edited by lost_in_code; Jun 20, 2008 at 08:38.

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    lic,

    I've not done it so I have no direct experience, however, Apache.org has your information.

    The REAL benefit to RewriteMap is that it's a load-once feature that can save immense time and effort. Using CGI/PHP scripting with db access is a major benefit that you will be able to take advantage of with your titles.

    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 Member lost_in_code's Avatar
    Join Date
    Jan 2004
    Location
    USA
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does anyone know how to do what DK is proposing... i.e. RewriteMap? Your help is greatly appreciated. Thank you.

  6. #6
    SitePoint Member lost_in_code's Avatar
    Join Date
    Jan 2004
    Location
    USA
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Who would be a good expert with something like this? Even if I have to hire someone, this is something I really need ASAP. Thank you very much.

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

    Did you check the link I gave you? That's the information from Apache.org on mod_rewrite and linked directly to the part about RewriteMap.

    RewriteMap is essentially a server-side file (or script with db access) which acts as a mapping device taking the URI input and redirecting according to the mapping in the file/script. The file is pretty simple as it's clearly a one-to-one mapping. Using a script is more complex as Apache will have to ask the script to run to ascertain whether it's supposed to redirect at all and, if so, where. Because the Apache.org people are PERL oriented, their examples are in PERL but you can easily translate to PHP, IMHO.

    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

  8. #8
    SitePoint Member lost_in_code's Avatar
    Join Date
    Jan 2004
    Location
    USA
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn View Post
    lic,

    Did you check the link I gave you? That's the information from Apache.org on mod_rewrite and linked directly to the part about RewriteMap.

    RewriteMap is essentially a server-side file (or script with db access) which acts as a mapping device taking the URI input and redirecting according to the mapping in the file/script. The file is pretty simple as it's clearly a one-to-one mapping. Using a script is more complex as Apache will have to ask the script to run to ascertain whether it's supposed to redirect at all and, if so, where. Because the Apache.org people are PERL oriented, their examples are in PERL but you can easily translate to PHP, IMHO.

    Regards,

    DK
    PM sent, thanks

  9. #9
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    lic,

    IF you would use URI's like (c(id)#|p(id)#)/p#/title, it would be as simple as:
    Code:
    RewriteEngine on
    RewriteRule ^/?c([0-9]+)(/p([0-9])?/([-a-z]+)\.html$ awm.xpi/store.html?p_scn=$4&p_cid=$1&page=$3 [L]
    RewriteRule ^/?p([0-9]+)(/p([0-9])?/([-a-z]+)\.html$ awm.xpi/products.html?p_scn=$4&p_cid=$1&page=$3 [L]
    The two cases are due to the use of two scripts to handle the input, store and products, which are designated by the leading c or p followed by their p_cid or p_pid numbers.

    The page is optional (as is the p# directory - so the inner atom is what you need to capture: $4).

    Finally, the "title" is captured as a lowercase string with -'s replacing the spaces - which, of course, is done by your link generating script.

    Two things to remember:

    1. YOU create your new links in the format (c|p)#/p#/title and mod_rewrite selects the appropriate script for you.

    2. The directory level will change with the redirect so DO NOT use relative links for your support files. With cgi-bin being outside the webspace, you have probably discovered that already!

    Sorry, simpler than it looked at first.

    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
  •