Lately, I stumbled upon an issue related to the way friendly url are rewritten:
The current .htaccess file defines the friendly urls rewrite rules as follows:
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Which means "if the requested file does not exist, or does not point to an actual directory, rewrite the url as index.php?q= ... followed by the original url path+parameters. Let be that the last rewrite action for this url". OK, so far so good. Now the problem:
Suppose that the main page contains a reference to an image say "/assets/notthere.jpg". What will happen now is that while loading the main page, the client will try to GET the /assets/notthere.jpg image. The server will not find the file and rewrite it to a new page. Hence a new request for the main page will be made, which still will contain a missing image, triggering a new page request and so forth.
In few words the rewrite rule is too forgiving. There should be a way to distinguish between
http://mysite.com/a-friendlyurl-dir/a-friendlyurl-article
and
http://mysite.com/assets/notthere.jpg
In principle you would like to redirect only the first and just issue a plain 404 for the second ...
In my opinion, the best way would be to strengthen the rewrite rule as follow:
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^.*/(assets|manager)/.+$
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
And possibly add any other directories which are not related to modx as well ...