htaccess/modrewrite help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #1

    htaccess/modrewrite help

    anyone use htaccess to create sub domains on the fly?

    i want to make it so if i am viewing a directory listing, when clicking on parent directory it goes back to the root of the sub domain, not the domain/subs/name.

    here is my htaccess.

    Code:
    # disable direct access to .htaccess
    
    <Files .htaccess>
     order allow,deny
     deny from all
    </Files>
    
    # disable direct access to other files
    
    <FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
     Order Allow,Deny
     Deny from all
    </FilesMatch>
    
    # cache images and flash content for one month
    
    <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$">
    Header set Cache-Control "max-age=2592000"
    </FilesMatch>
    
    # cache text, css, and javascript files for one week
    
    <FilesMatch ".(js|css|pdf|txt)$">
    Header set Cache-Control "max-age=604800"
    </FilesMatch>
    
    # cache html and htm files for one day
    
    <FilesMatch ".(html|htm)$">
    Header set Cache-Control "max-age=43200"
    </FilesMatch>
    
    # enable symbolic links
    Options +FollowSymLinks
    
    # lets use some rewrites
    
    RewriteEngine On
    
    # remove www
    
    RewriteCond %{HTTP_HOST} ^www\.(domain\.com)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    
    # treat .php as .html
    # example: /downloads/files.php will work as /downloads/files.html
    
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{REQUEST_URI} ^(/.+\.)html$ [NC]
    RewriteCond %{DOCUMENT_ROOT}%1php -f
    RewriteRule \.html$ %1php [NC,QSA,L]
    
    # images on the root.
    # example /images/chicago.jpg will work as /chicago.jpg
    
    RewriteCond %{DOCUMENT_ROOT}/images%{REQUEST_URI} -f [OR]
    RewriteCond %{DOCUMENT_ROOT}/images%{REQUEST_URI} -d
    RewriteRule !^images(/.*)?$ /images%{REQUEST_URI} [QSA,L]
    
    # sub domains on the fly
    
    RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
    RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+)\.domain\.com$ [NC]
    RewriteCond %{DOCUMENT_ROOT}/subs/%2%{REQUEST_URI}/ -d
    RewriteRule [^/]$ http://%2.domain.com%{REQUEST_URI}/ [R=301,L]
    RewriteCond %{HTTP_HOST} ^.*\.([^\.]+\.domain\.com)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
    RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
    RewriteCond %1:::%{REQUEST_URI} !^(.+):::/subs/\1(/.*)?$ [NC]
    RewriteCond %{DOCUMENT_ROOT}/subs/%1/ -d
    RewriteRule ^(.*)$ /subs/%1/$1 [QSA,L]
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #2
    afternoon bump
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

    Comment

    • V_RocKs
      Damn Right I Kiss Ass!
      • Nov 2003
      • 32449

      #3
      Code:
      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTP_HOST} .
      RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
      RewriteCond %{HTTP_HOST} ^(sub)\.domain\.com
      RewriteRule ^(.*) http://www.domain.com/subdomains/sub/$1 [L,P]

      Comment

      • V_RocKs
        Damn Right I Kiss Ass!
        • Nov 2003
        • 32449

        #4
        P flag is supposed to keep things going via internal proxy instead of making the switch in the browsers address bar. I didn't test it though...

        Comment

        • Juicy D. Links
          So Fucking Banned
          • Apr 2001
          • 122992

          #5
          Code:
          # pussy lips
          
          
          
          RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC] pussy lips
          RewriteCond %{HTTP_HOST} ^(.*\.)?([^\.]+)\.domain\.com$ [NC]
          RewriteCond %{DOCUMENT_ROOT}/subs/%2%{REQUEST_URI}/ -d
          RewriteRule [^/]$ http://%2.domain.com%{REQUEST_URI}/ [R=301,L]
          RewriteCond %{HTTP_HOST} ^.*\.([^\.]+\.domain\.com)$ [NC]
          RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
          RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
          RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
          RewriteCond %1:::%{REQUEST_URI} !^(.+):::/subs/\1(/.*)?$ [NC]
          RewriteCond %{DOCUMENT_ROOT}/subs/%1/ -d pussy lips
          RewriteRule ^(.*)$ /subs/%1/$1 [QSA,L]

          Comment

          • RyuLion
            • Mar 2003
            • 32369

            #6
            Be careful with that..

            Adult Biz Consultant A tech head since 1995
            Affiliate Support: Chaturbate | CCBill Live

            Comment

            Working...