Need special .htaccess

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • God-o-Sex
    Registered User
    • Apr 2002
    • 57

    #1

    Need special .htaccess

    Hi all!

    I am needing some kind of special .htaccess file for my hosting service that determines the location I came from and then redirects it to a certain directory.

    Let's say a user types in:

    http://test.mydomain.com

    Now the .htaccess should automatically forward that URL to:

    http://www.mydomain.com/test

    I know that there are some out there, but I couldn't find it yet. Hope you can help me with that.

    Thanks a lot.
    Free bannerless hosting for TGP, TGP2 and Movie galleries - Including unlimited domains and bandwith, MySQL, CGI-BIN
    Sign up here!!!
  • spanky
    Confirmed User
    • Apr 2002
    • 231

    #2
    http://httpd.apache.org/docs/misc/rewriteguide.html

    cheers

    Comment

    • God-o-Sex
      Registered User
      • Apr 2002
      • 57

      #3
      Thank you Spanky.

      Just wondering if "Path-forwarding" will also work with that. So:

      http://i.could.write.anything.here.mydomain.com

      will forward to:

      http://mydomain.com/here
      Free bannerless hosting for TGP, TGP2 and Movie galleries - Including unlimited domains and bandwith, MySQL, CGI-BIN
      Sign up here!!!

      Comment

      • spanky
        Confirmed User
        • Apr 2002
        • 231

        #4
        yeah, you ought to be able to get it as long as you get the right regular expression in the rewrite rules.

        cheers

        Comment

        • NetRodent
          Confirmed User
          • Jan 2002
          • 3985

          #5
          If you have access to your httpd.conf file, you can do what you want very simply. Here's a very simple pair of virtual host record that will redirect http://anything.domain.com/ to http://www.domain.com/here


          <VirtualHost 127.0.0.1>
          ServerName domain.com
          ServerAlias *.domain.com
          Redirect / http://www.domain.com/here
          ErrorLog /logs/domain.com-error_log
          CustomLog /logs/domain.com-access_log CustomLog
          </VirtualHost>

          <VirtualHost 127.0.0.1>
          ServerName www.domain.com
          DocumentRoot /webdata/domain.com
          ErrorLog /logs/domain.com-error_log
          CustomLog /logs/domain.com-access_log CustomLog
          ErrorDocument 404 http://www.domain.com/
          </VirtualHost>
          "Every normal man must be tempted, at times, to spit on his hands, hoist the black flag, and begin slitting throats."
          --H.L. Mencken

          Comment

          • JFPdude
            Confirmed User
            • Jan 2002
            • 4027

            #6
            Why not just ask your host for a wildcard DNS entry. Works great and you don't have to mess with an .htaccess file

            Comment

            • mike503
              Confirmed User
              • May 2002
              • 2243

              #7
              or you could write a perl or php script for it as well. there are many options
              php/mysql guru. hosting, coding, all that jazz.

              Comment

              • foe
                Confirmed User
                • May 2002
                • 5246

                #8
                Writting a perl/php script for that Is a pretty bad Idea Using wildcards in apache config is the accepted practice Is a lot faster and will be less buggy. But make sure if you have other subdomains you place


                ServerName domain.com
                ServerAlias *.domain.com
                Redirect / http://www.domain.com/here
                ErrorLog /logs/domain.com-error_log
                CustomLog /logs/domain.com-access_log CustomLog


                after them so apache redirects to the subdomains first.

                Comment

                Working...