.htaccess - url rewriting everything to index.php except few is not working for a saas application -


i using code in htaccess file redirect requests index.php , works.

rewriteengine on  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d  rewriterule ^(.*)$ index.php [l,qsa] 

now, trying redirect few requests file public.php (i..e load everthing via index.php if user logged in, otherwise load files via public.php - that's idea)

i have tried several methods works others none of them seems working me., have no idea why.

the application structure is

[folder] app www static .htaccess 

and .htaccess used in root folder

rewritecond %{http_host} ^(www.)?website.com rewriterule ^(.*)$ www/index.php?$1 [l,qsa]   rewritecond %{http_host} ^(static.)?website.com rewriterule ^(.*)$ static/index.php?$1 [l,qsa]   rewritecond %{http_host} ^([^.]+)\.website\.com$ [nc]  rewriterule ^(.*)$ app/index.php?$1 [l,qsa] 

by default if subdomain www or static files loaded www , static folders respectively. if url accessed via other subdomain files loaded app directory.

the codes tried are

rewriteengine on  rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d  rewriterule ^public$ public.php [l,qsa] rewriterule ^(.*)$ index.php [l,qsa] 

interchanged these 2 lines tried removing l, qsa

and many others.., many find on google + stackoverflow., none of them worked, i guess not working due how have coded .htaccess file in root directory.

if guys can find obvious problems htaccess codes please let me know how fix it, no matter how try learn htaccess suck @ it, if know of tutorial related please post link well.., googled , read many articles on already.

it took little reallize wrong, here is...

rewriteengine on  # first line: if filename contains public.php, dont rewrite again. # second line: if requested uri contains /public, rewrite public.php rewritecond %{request_filename} !/public.php [nc] rewritecond %{request_uri} ^/public rewriterule ^(.*)$ public.php?$1 [l]   # here layed problem, not want rewrite requested uri if pointing actual file on server. # thus, condition rewriting index.php, file not exist. # second condition directory not exist. not sure need though. rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php?$ [l] 

thus, problem 3th htaccess, "rewritecond %{request_filename} !-f" working on "public" rewrite, not on index.php should. hope solves problem!


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -