htaccess Configuration per Directory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hdlee
    Junior Member
    • Dec 2004
    • 6

    #1

    htaccess Configuration per Directory

    Is it allowable in Dathorn?

    I want to be able to set different configuration for directories. Say, all .html files should be processed as .php in directory "directory".

    Is htaccess configuration per directory allowable?

    Thanks.
  • Buddha
    Senior Member
    • Mar 2004
    • 825

    #2
    Yes you have htaccess at Dathorn and Apache will look for htaccess file in all directories in the file path. Never used <Directory> block in a htaccess file but I think you can do what you described even with out it.

    [Edit to add]

    I'm just a customer.
    "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

    Comment

    • Jonathan
      Senior Member
      • Mar 2004
      • 1229

      #3
      One of the moderators here posted a example .htaccess file for
      putting PHP in .htm or .html files (you can adjust for any file name):
      Have you ever wished you could execute PHP scripts within your HTML files? If you have worked with PHP at all in the past, I am sure there have been times when coding PHP right into your .html files would have been very convenient, not to mention a time saver. This tutorial will show you how to parse your PHP scripts into .html

      [Just a customer]
      "How can someone be so distracted yet so focused?"
      - C

      Comment

      • hdlee
        Junior Member
        • Dec 2004
        • 6

        #4
        Thanks

        That was fast.

        I am looking forward to be a customer real soon, hopefully next week.

        It is very important for me, I need that feature because:
        1. My blog (WordPress) needs ModRewrite to convert dynamic URL into
        search engine friendly URL.
        2. I need to embed PHP command into .htm and .html, or omit extension overall.

        and many others I can't even think of right now because of the cold.

        Thanks again!

        Comment

        • Jonathan
          Senior Member
          • Mar 2004
          • 1229

          #5
          Oh and we got a good community
          IMHO thats a huge bonus

          As for using mod rewrite and embedding PHP into .htm and .html,
          I've done both so that should not be a problem
          "How can someone be so distracted yet so focused?"
          - C

          Comment

          • blakekr
            Member
            • Dec 2004
            • 30

            #6
            Jonathan, would you mind posting your mod rewrite code, I just put some in my .htaccess but it doesn't seem to be working, and I'm not all that good with mod rewrite anyway ...

            Anyway, thanks if you don't mind!

            Comment

            • Jonathan
              Senior Member
              • Mar 2004
              • 1229

              #7
              AddType application/x-httpd-php .php .htm .html .shtml

              ^^ That's all I use, but right now I can't
              seem to get it to work with the extention ".GD" that I was trying to use.
              "How can someone be so distracted yet so focused?"
              - C

              Comment

              • hdlee
                Junior Member
                • Dec 2004
                • 6

                #8
                i use above code, and from the link you gave to me too. even use the same .htaccess I use on the other webhost. but it won't work.

                when i tried with a file, even with phpinfo.html, which contain only the following line:

                <? phpinfo(); ?>

                and monitor the error log, it said:

                [2005-01-04 21:28:34]: error: file has no execute permission: (/home/xstopeb3/public_html/trydir/phpinfo.html)

                [Tue Jan 4 21:37:37 2005] [error] [client 203.160.233.26] Premature end of script headers: /home/xstopeb3/public_html/trydir/phpinfo.html

                You can access the file here:



                the "trydir" contain:

                .htaccess:

                AddType application/x-httpd-php .html .php .htm

                phpinfo.html:

                <? phpinfo(); ?>

                That's all.

                Hope that it's clear. Thanks for your time.

                P.S. I should've probably mention that the file is created under linux vi command (from an ssh terminal session right on the server). Using the DOS format, it won't work also.

                P.P.S. I've tried to change the permission of files to 755 too, but it doesn't make any sense if I have to do this. Another thing, it runs properly from php command line. $ php trydir/phpinfo.html give the right output.

                Comment

                • hdlee
                  Junior Member
                  • Dec 2004
                  • 6

                  #9
                  I've solved the problem. I add this to the .htaccess:

                  SetHandler application/x-httpd-php

                  Don't know why I need to do this, it works without it in my other web host running linux and openbsd.

                  anyway, it works now.

                  Comment

                  • Jonathan
                    Senior Member
                    • Mar 2004
                    • 1229

                    #10
                    odd The code I posted worked fine for me.
                    Glad to see you got it to work for you
                    "How can someone be so distracted yet so focused?"
                    - C

                    Comment

                    Working...