I have trouble understanding the way htaccess works.
This is the folder structure (approximate sample)
# DocumentRoot
# |-- main
# | |-- site
# | | |-- assets
# | | | |-- test.js
# | | |-- index.php
# | |
# | |-- common
# | | |-- assets
# | | | |-- test.js
# | |
# | |-- .htaccess
These are the sample redirects I'm hoping to achieve
# http://www.example.com/main/assets/test.js => /main/site/assets/test.js
# http://www.example.com/main/common/assets/test.js => /main/common/assets/test.js
# http://www.example.com/main/common/path/to/file => /main/common/path/to/file
# http://www.example.com/main => /main/site/index.php
# http://www.example.com/main/part/url => /main/site/index.php
My attempt at htaccess file looks like this:
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^assets/(.*)$ site/assets/$1 [L]
RewriteRule ^common/(.*)$ common/$1 [L]
RewriteRule ^(.*)$ site/index.php [L]
My Problem: Every Url gets routed to index.php. What have I understood wrong?
Currently all processing for the query and partial url is handled in php. I only need to serve resources from the two asset folders and any other urls to go to the index.php.
Sorry if this looks like I'm trying to get my fish for the day but learning to fish i.e. experimenting is getting me nowhere.
Thanks in advance for all the help.