.htaccess to permanently forward dynamic page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maartenvr
    Junior Member
    • Jul 2004
    • 24

    .htaccess to permanently forward dynamic page

    I am trying to use .htaccess to permanently forward dynamic pages. I tried the following:

    Code:
    RewriteCond %{QUERY_STRING} ^prod=widgets$ 
    RewriteRule ^shop/proddetail\.php$ http://www.site.com/shop/page.php [R=301,L]
    But this is not working... what am I doing wrong?
    Maarten Van Ruitenburg
    Professional Web Site Design
  • ZYV
    Senior Member
    • Sep 2005
    • 315

    #2
    Looks like if the problem were is RewriteCond. Try it without ^ & $ and also, it seemed to me that there should be some other way to read GET variables. Hm...

    Comment

    • maartenvr
      Junior Member
      • Jul 2004
      • 24

      #3
      Originally posted by ZYV
      Looks like if the problem were is RewriteCond. Try it without ^ & $ and also, it seemed to me that there should be some other way to read GET variables. Hm...
      Nope, that did not do it
      Maarten Van Ruitenburg
      Professional Web Site Design

      Comment

      • sdjl
        Senior Member
        • Mar 2004
        • 502

        #4
        Do you get any errors?

        ^ and $ are generally needed to dictate the start and end delimiters to the condition.

        David
        -----
        Do you fear the obsolescence of the metanarrative apparatus of legitimation?

        Comment

        • maartenvr
          Junior Member
          • Jul 2004
          • 24

          #5
          Nope, no errors!
          Maarten Van Ruitenburg
          Professional Web Site Design

          Comment

          • sdjl
            Senior Member
            • Mar 2004
            • 502

            #6
            Is that no errors shown on the page or no errors in the error log under cPanel?
            I find that the error log produces some good information even if the browser doesnt show it

            David
            -----
            Do you fear the obsolescence of the metanarrative apparatus of legitimation?

            Comment

            • maartenvr
              Junior Member
              • Jul 2004
              • 24

              #7
              Nope, nothing in the error log...
              Maarten Van Ruitenburg
              Professional Web Site Design

              Comment

              • ZYV
                Senior Member
                • Sep 2005
                • 315

                #8
                Actually I think that your assumptions on the content of QS are wrong. Try to print it out via PHP:
                PHP Code:
                <?php echo $_SERVER["QUERY_STRING"]; ?>
                I've also found an example similar to what you are trying to achieve:

                Code:
                ----* 	mod_rewrite: transparent CGI redirect
                
                Instead of test.shtml?parm=N we'll show /cgi-bin/test.cgi?param=1
                
                    RewriteCond %{REQUEST_URI} /test.shtml
                    RewriteCond %{QUERY_STRING} param=[0-9]+
                    RewriteRule ^(.+) $1/%{QUERY_STRING}  [C]
                    RewriteRule ^/test.shtml/param=([0-9]+) /home/user/cgi-bin/test.cgi?param=$1 [T=application/x-httpd-cgi,L]
                Note that there is no ^/$ begin/end delimiters.

                Comment

                • maartenvr
                  Junior Member
                  • Jul 2004
                  • 24

                  #9
                  This one seems kinda backwards to me...? I don't need to go from static to dynamic, but the other way around...
                  Maarten Van Ruitenburg
                  Professional Web Site Design

                  Comment

                  • sdjl
                    Senior Member
                    • Mar 2004
                    • 502

                    #10
                    How about doing it all in one line. Not as astehtically pleaseing, but you never know, it may work

                    Code:
                    RewriteRule ^shop/proddetail\.php\?prod=widgets$ http://www.site.com/shop/page.php [R=301,L]
                    David
                    -----
                    Do you fear the obsolescence of the metanarrative apparatus of legitimation?

                    Comment

                    • maartenvr
                      Junior Member
                      • Jul 2004
                      • 24

                      #11
                      Nope, that still doesn't do it... I have tried so many things.... but nothing has worked yet!
                      Maarten Van Ruitenburg
                      Professional Web Site Design

                      Comment

                      Working...