GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   htaccess/modrewrite help (https://gfy.com/showthread.php?t=1022750)

fris 05-16-2011 08:17 AM

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]


fris 05-16-2011 01:18 PM

afternoon bump

V_RocKs 05-16-2011 01:40 PM

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]


V_RocKs 05-16-2011 01:41 PM

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...

Juicy D. Links 05-16-2011 03:08 PM

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]


RyuLion 05-16-2011 03:16 PM

Be careful with that..


All times are GMT -7. The time now is 08:57 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123