Redirecting Dynamic Page to static page.

Discussion in 'Apache' started by joe_mat, Aug 27, 2007.

  1. #1
    Hello,

    I am having a website where i am having dynamic URL pages in with .php extension.

    eg:http://www.mydomain.com/subcategory.php?subcatID=5&subname=nokia-n70

    i can have redirection code on. .htacces file like

    Options +FollowSymLinks
    RewriteEngine on


    RewriteRule ^category/([0-9]+)]+)/([0-9A-Za-z]+).html$ subcategory.php?subcatID=$1&subname=$2 [L]



    and on php page i having have code that create dynamic pages to static pages.

    echo "<a href='http://www.".$DOMAIN_NAME."/category/".$rw_sub[0]."/".
    format_str(stripslashes($rw_sub[1])).".html'>".$rw_sub[1]."</A></DIV>";



    it is creating my dynamic links to static links.
    http://www.mydomain.com/category/5/nokia-n70.html

    but when i click on that link i didn't find that pages there because i am not having that static html page on that specific static location.

    i just wanna know is it possible to have that static pages there without creating them manually.

    like if i have dynamic page as :
    http://www.mydomain.com/subcategory.php?subcatID=5&subname=nokia-n70

    and it became static as :
    http://www.mydomain.com/category/5/nokia-n70.html

    but can i have this static page there without make it manually on that location.

    Please suggest.

    Thanks
     
    joe_mat, Aug 27, 2007 IP
  2. DeViAnThans3

    DeViAnThans3 Peon

    Messages:
    785
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Like you already said, you should use mod_rewrite
    http://www.mydomain.com/subcategory.php?subcatID=5&subname=nokia-n70
    rewrite to
    category/5/nokia-n70.html

    You already gave the solution yourself; however I'll edit it a bit, maybe it'll work better that way.
    Put the following code to your .htaccess file in the root folder (www.mydomain.com).
    RewriteEngine on
    RewriteRule ^category/([^/\.]+)/([^/\.]+).html?$ subcategory.php?subcatID=$1&subname=$2 [L]
    Code (markup):
    Let's know whether or not it works. Make sure the .htaccess file is only put in the root folder!
     
    DeViAnThans3, Aug 27, 2007 IP
  3. joe_mat

    joe_mat Peon

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hello,

    I have done wht you suggest and that .thaccess and php code make my menu link static from

    http://www.mydomain.com/subcategory....name=nokia-n70

    to

    http://www.mydomain.com/category/5/nokia-n70.html

    But when i click on these static link then its show me a blank page with " Page Cannot be

    found" error.
    because i am not having that static html page on that specific static location.

    It is nessecry to create that page nokia-n70.html manually there at specific location

    "http://www.mydomain.com/category/5/"

    Or it can be happen automaticlly
    please suggest

    thanks

     
    joe_mat, Aug 27, 2007 IP
  4. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #4
    try

    
    RewriteRule ^category/([0-9]+)/([0-9A-Z]+).html$ subcategory.php?subcatID=$1&subname=$2 [L,NC]
    
    Code (markup):
    the first () in your rewriterule seemed to have a few extra characters in it
     
    powerspike, Aug 27, 2007 IP