Quote:
Originally Posted by jag1
RewriteRule ^knowledge-center/(\d+)(?:/.*)?$ knowledge-center-desc.php?id=$1 [QSA,L,NC]
|
You don't state what the URLs are that are being requested (for the images, CSS and JS files). However, the above rewrite would also catch images, CSS and JS files if they are of the form "/knowledge-center/123/image.jpg" etc. And these would all be rewritten to "knowledge-center-desc.php" - although this would probably just result in a bunch of 404s, not a 500.
Quote:
Originally Posted by jag1
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
|
However, this could result in a rewrite-loop (500 error) depending on the URL being requested, since the file check (2nd condition) is not necessarily the same as the URL being rewritten to. The first condition (that checks whether the request maps to a directory) is most probably superfluous. You should change this to:
Code:
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
You could also exclude (at the top of the file) all requests that look like images, CSS or JS files from being rewritten - this would be a good optimisation anyway. For example, add the following at the top of the .htaccess file, immediately after the RewriteEngine directive:
Code:
# Ignore any requests that contain an image, css or js file extension
RewriteRule \.(jpg|png|gif|css|js)$ - [L]
This then prevents images, css and js files from being processed any further - which should also prevent these resources from triggering a rewrite loop (most probable cause of the 500 error).