mod rewrite - AngularJS + PHP api -


this folder structure:

myproject/     api/         api.php     public/         .htaccess         index.html         scripts/             ... angular stuff... 

my .htaccess follows:

rewriteengine on # if existing asset or directory requested go rewritecond %{document_root}%{request_uri} -f [or] rewritecond %{document_root}%{request_uri} -d rewriterule ^ - [l]  rewriterule ^/api/ ../api/api.php  # if requested resource doesn't exist, use index.html rewriterule ^ /index.html 

so, want this: accessing http://localhost returns index.html. ajax calls within angularjs scrips /api/something should handled api.php file.

currently, apache virtual host points myproject/public. accessing http://localhost works fine (it returns index.html) calls /api/something returns index.html. seems api.php never reached. ideas?

i dont think can make work double dots not ending processing of rules.

so, after matches api, goes on last rule , rewrites index.html

add [l] @ end of api line, so:

rewriterule ^/api/ ../api/api.php [l] 

adding this, since needed :), if want know 'something' in api.php pass rest or url (after api) parameter

rewriterule    ^api/(.+)$    <whatever_url_work>/api.php?action=$1    [nc,l] 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Apache Thrift Tutorial Error -