mod_rewrite directives in .htaccess

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • juanmanuel
    Junior Member
    • Mar 2004
    • 4

    #1

    mod_rewrite directives in .htaccess

    Hi! Are mod_rewrite directives in .htaccess allowed in the servers I need to install a contribution in OSC. Thanks.
  • Ihost
    Junior Member
    • Mar 2004
    • 22

    #2
    Yes they are. We are using them on our site to do 301 redirects.
    Kerry Slavin
    Reliable Solution Internet Services
    For the best independent support for webhosts & their customers visit -
    JointSupportForum.Com

    Comment

    • -Oz-
      Senior Member
      • Mar 2004
      • 545

      #3
      I use them all the time to send "folders" to php scripts.
      Dan Blomberg

      Comment

      • petert
        Junior Member
        • May 2004
        • 8

        #4
        Originally posted by -Oz-
        I use them all the time to send "folders" to php scripts.
        Can you give me an example of the code I need to put in my .htaccess file
        to redirect folders to scripts?

        Thanks,
        Peter

        Comment

        • superfly
          Member
          • Mar 2004
          • 80

          #5
          I've got a similar problem so I'll post it here if ok =)

          this is my index.php:
          --------------------------
          or ($i=1; $i < 10; $i++)
          {
          echo '<a href="index.php?l='.$i.'">Link '.$i.'</a><br />';
          }
          ---------------------------

          and this is my .htaccess file:
          ----------------------------
          RewriteEngine On
          RewriteRule ^index/(.*).php /index.php?l=$1
          ----------------------------

          Both files are in public_html/

          The links wont rewrite... what am I doing wrong?

          Comment

          • Buddha
            Senior Member
            • Mar 2004
            • 825

            #6
            Originally posted by superfly
            RewriteEngine On
            RewriteRule ^index/(.*).php /index.php?l=$1
            First problem that I see... Periods are special characters in regular expressions. To find an actual period you need to use a backslash like this:
            Code:
            \.
            Second problem... If index is a directory then it should probably begin with a forwardslash unless your using RewriteBase.

            See if this works...
            Code:
            RewriteEngine On 
            RewriteRule ^/index/(.*)\.php /index.php?l=$1
            "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

            Comment

            • petert
              Junior Member
              • May 2004
              • 8

              #7
              The links wont rewrite... what am I doing wrong?
              I don't think mod_rewrite solution works on Dathorn servers.
              I've asked Andrew and he said he is not sure if this is going to work.

              The ForceType directive in .htaccess doesn't work either .

              Does anybody using Dathorn servers has implemented search engine friendly URLs and if yes, how?

              Thanks,
              Peter

              Comment

              • superfly
                Member
                • Mar 2004
                • 80

                #8
                Actually it does work... i tried going to domain.net/index/1.php and it worked. yay. =)

                Comment

                • Jonathan
                  Senior Member
                  • Mar 2004
                  • 1229

                  #9
                  I believe Oz uses it for "search engine friendly"
                  URLs in his CMS scripts that he makes.
                  "How can someone be so distracted yet so focused?"
                  - C

                  Comment

                  • petert
                    Junior Member
                    • May 2004
                    • 8

                    #10
                    Hi guys,

                    I need some help with mod_rewrite please.
                    I've tried Buddha's example and it didn't work.
                    Here is my setup:

                    .htaccess file in the root of public_html folder

                    this is the .htaccess content

                    Code:
                    RewriteEngine On 
                    RewriteRule ^/article/(.*)\.php /article.php?l=$1
                    .htaccess has 755 permissions

                    =========================================

                    article.php in the root of public_html folder

                    =========================================

                    When I type:

                    http://my-domain-name.com/article/something-here.php

                    I get Not Found error.


                    What am I doing wrong?


                    Thanks in advance,
                    Peter

                    Comment

                    • Buddha
                      Senior Member
                      • Mar 2004
                      • 825

                      #11
                      If you have an "article" directory, I think you might get a 404.

                      Just a note of caution: You can create an endless loop with a rewrite, just be careful what your doing.
                      Last edited by Buddha; 05-20-2004, 10:00 PM.
                      "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

                      Comment

                      • petert
                        Junior Member
                        • May 2004
                        • 8

                        #12
                        Originally posted by Buddha
                        If you have an "article" directory, I think you might get a 404.

                        Just a note of caution: You can create an endless loop with a rewrite, just be careful what your doing.
                        I don't have article folder, but I've renamed the file to article1.php just in case and I've changed it the .htaccess file too - got the same error again

                        Comment

                        • petert
                          Junior Member
                          • May 2004
                          • 8

                          #13
                          I fixed the problem .

                          The rewrite rule line was wrong. It was:

                          Code:
                          RewriteRule ^/article/(.*)\.php /article.php?l=$1
                          and I've changed to:

                          Code:
                          RewriteRule ^article/(.*)\.php /article.php?l=$1
                          and now it finds article.php


                          Thanks for the help guys,

                          Peter

                          Comment

                          • Jonathan
                            Senior Member
                            • Mar 2004
                            • 1229

                            #14
                            mm, I'm wondering;

                            I'm thinking of making my new site using
                            PHP includes, and a file.php?id=casename
                            sort of URL........

                            Basicly, load the include as if it
                            were an iFrame file, except of course ~ it isn't.

                            But, could I use (and if so, how) mod rewrite
                            to make 'index.php?id=hosting' actually show, in the URL
                            as 'domain.com/hosting/' ? Basicly, for search-engine friendly URLs...
                            "How can someone be so distracted yet so focused?"
                            - C

                            Comment

                            • Buddha
                              Senior Member
                              • Mar 2004
                              • 825

                              #15
                              Jonathan you wouldn't need to do a mod_rewrite if you let Apache do it's job as the front controller. I would think that PHP-Nuke's front controller architecture would be one of the problem you would want to avoid in your own CMS?

                              petert: Sorry been writing too many rewrite rules in .conf you don't need that leading slash in .htaccess.
                              "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

                              Comment

                              Working...