Friday, 15 January 2010

regex - .htaccess remove public folder and index.php in subdirectory -



regex - .htaccess remove public folder and index.php in subdirectory -

i'm building api devided in subfolders. version 1 of api located in api.com/v1 , next version version four, located in /v4.

version 1 wasn't using framework , straight php. version 4 of api using laravel base. resulting in public folder. don't want api urls 'api.com/v4/public/entry'.

filtering index.php out of url's worked fine provided .htaccess, didn't filter out public folder , index.php file, while keeping v4 subdirectory in url.

i'm not sure if possible @ all.

so api.com/v4/img/banner.png should link api.com/v4/public/img/banner.png. , api.com/v4/gis/layer1.xml should link api.com/v4/public/index.php/gis/layer1.xml

here goes .htaccess file far, located in v4 folder. (modified version of .htaccess file located in public folder used filter out 'index.php' url.)

rewriteengine on # add together basic auth back upwards rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule .* - [e=http_authorization:%{http:authorization}] # next rule tells apache if requested filename # exists, serve it. rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] # next rewrites other queries index.php. # status ensures if using apache aliases # mass virtual hosting, base of operations path prepended # allow proper resolution of index.php file; work # in non-aliased environments well, providing safe, one-size # fits solution. rewritecond %{request_uri}::$1 ^(/.+)(.+)::\2$ rewriterule ^(.*) - [e=base:%1] rewriterule ^(.*)$ %{env:base}public/index.php [nc,l]

php regex apache .htaccess mod-rewrite

No comments:

Post a Comment