how to create .htaccess file in PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mukeshrasm
    Contributor
    • Nov 2007
    • 254

    how to create .htaccess file in PHP

    Hello I want to create .htaccess file in PHP and for website why do we require to have this file. means what are the advantage if I create.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by mukeshrasm
    Hello I want to create .htaccess file in PHP and for website why do we require to have this file. means what are the advantage if I create.
    .htaccess files are good for many things. One of the more notable possibilities with using .htaccess is the creation of 'pretty urls' where you take a url that looks like
    Code:
    www.somesite.com/?id=this&item=is&auth=now&p=pretty
    Quite ugly, no? And change it into this:
    Code:
    www.somesite.com/this/is/now/pretty
    Looks alot better, right?

    This is all done with simple RewriteRule's

    I've heard .htaccess files are pretty resource intensive though.. meaning theyre bandwidth hungry. Not sure about the credibility of this statement, though.

    Hope this helps!

    Comment

    • mukeshrasm
      Contributor
      • Nov 2007
      • 254

      #3
      Originally posted by markusn00b
      .htaccess files are good for many things. One of the more notable possibilities with using .htaccess is the creation of 'pretty urls' where you take a url that looks like
      Code:
      www.somesite.com/?id=this&item=is&auth=now&p=pretty
      Quite ugly, no? And change it into this:
      Code:
      www.somesite.com/this/is/now/pretty
      Looks alot better, right?

      This is all done with simple RewriteRule's

      I've heard .htaccess files are pretty resource intensive though.. meaning theyre bandwidth hungry. Not sure about the credibility of this statement, though.

      Hope this helps!
      Thanks for the information. But how can I create .htaccess file

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by mukeshrasm
        Thanks for the information. But how can I create .htaccess file
        Create a file, any file, then save the file named as .htaccess

        Simple.

        Comment

        • mukeshrasm
          Contributor
          • Nov 2007
          • 254

          #5
          Originally posted by markusn00b
          Create a file, any file, then save the file named as .htaccess

          Simple.
          ok but how the url wil look like this

          www.somesite.co m/this/is/now/pretty

          as you have given example above.

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            Originally posted by mukeshrasm
            ok but how the url wil look like this

            www.somesite.co m/this/is/now/pretty

            as you have given example above.
            Well you need to create a rule inside the file.

            Try a tutorial on rewriting

            Comment

            Working...