5 Replies Latest reply on Oct 13, 2008 6:24 AM by (phil_amoh)

    Apache RewriteRule Help wanted.

    Level 1
      I have old dynamic links basically of the forms:

      index.php?go=news
      and
      index.php?go=newsdetail&id_news=x where X is the item id pulled from database.

      I wanted to rewrite the following to:
      /about/ and
      /news/4.htm,

      I am using the following directives:
      RewriteRule ^news\.htm index.php?go=news
      RewriteRule ^news/([0-9]+)\.htm index.php?go=newsdetail&id_news=$1

      I'm having two issues with this now.
      1. when the old urls are typed in, they still show in the address bar. I've added [R=301,L] to the end of the rewrite rules but then it gives me a 403 error message. How do I correct this?

      2. When I use the links like above, it seems I lose the base href and so I don't get images, css and javascripts showing as they point to the wrong files. I know trying relative links like img src=/images/image.gif would work on the server but during development, the files are stored in individual folders for the different websites.

      Hope I've been able to explain myself well.
        • 1. Re: Apache RewriteRule Help wanted.
          Level 1
          http://www.sitepoint.com/article/guide-url-rewriting/
          • 2. Re: Apache RewriteRule Help wanted.
            Level 1
            Thanks Purple Edge.
            I've already taken a look at that article already, but it does not address my needs

            >I'm having two issues with this now.
            >1. when the old urls are typed in, they still show in the address bar. >I've added [R=301,L] to the end of the rewrite rules but then it gives me a 403 error message. How do I correct this?

            >2. When I use the links like above, it seems I lose the base href and so I don't get images, css and javascripts showing as they point to the wrong files. I know trying relative links like img src=/images/image.gif would work on the server but during development, the files are stored in individual folders for the different websites.

            Hope you understand my problem now.
            • 3. Re: Apache RewriteRule Help wanted.
              Level 1
              1.

              http://forum.modrewrite.com/viewtopic.php?t=3914&sid=22128faccb18cac11f4c0dba4b729d0c

              2. See 1 [g], or trying to get things to work on a local server VS the live site is something I also struggle with!
              • 4. Re: Apache RewriteRule Help wanted.
                Level 1
                Hi Phil,

                I have been wrestling with this for some time, and finally found a page that will actually generate a rewrite rule that works! (And work with ADDT dynamic Includes!) I hope it works for you...

                http://xem247.com/tool/htaccess.php

                There are other tools listed at...

                http://www.blogsdna.com/754/top-5-online-htaccess-mod-rewrite-rules-generator-website-blog s.htm

                For your first example (mod instead of go)...

                Options FollowSymLinks
                RewriteEngine On
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteRule ^([^/]+)/?$ index.php?mod=$1& [L,NC]

                I am using at...

                www.comformark.com.au/aboutus
                • 5. Re: Apache RewriteRule Help wanted.
                  Level 1
                  Thanks Purple Edge,
                  Would try these and get let you in on what happens.