Wednesday, August 1, 2012

htaccess

rewrite to nothing (-) and stop ([L] flag)

-f: file exist

-d: directory exist

-l:symbol link exist

-s: file content length not zero

NC|nocase: no case up and low

NS|nosubreq:  no internal sub-request

qsappend|QSA:query string append

noescape|NE: no URI escaping

type|T=MIME-type:

next|N: next round

last|L: last

chain|C:chained

proxy|P: proxy

gone|G: gone http code 410

forbidden|F:forbidden

redirect|R [=code]:redirect

ornext|OR: not default and

nocase|NC: TestString + CondPattern

skip|S=num: skip follow num items regular

1.redirect

from http://webserver/project/* are being passed to the/var/www/project/public/index.php

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /project/public/index.php [NC,L]


2.multi sub site


Given this directory structure:

/home/branches/branch1/public/index.php
/home/branches/branch2/public/index.php
/home/branches/branch3/public/index.php

How can I access these like so:

branch1.branch.example.com
branch2.branch.example.com
branch3.branch.example.com

Without having to hardcode in each branch?

Here's my starting point (source), (I somehow can't even get this to work at the moment, but I swear it was working this morning, ha!).

ServerAlias *.branch.example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} .* [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.branch\.example\.com
RewriteCond /home/branches/%1/public
RewriteRule ^(.*) /%1/$1 [L]



3.common

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]



 


4. rewrite

No comments: