BOTJr. BOTJr. - 3 months ago 14
PHP Question

.htaccess friendly URLs weird behavior

I have a

query.php
file on my server whose location is
ROOT_DIRECTORY/info/query.php
.

There is no problem with the script untill i used friendly Urls in my .htaccess file.I have used them to many scripts and they are working perfectly fine but when i add these two lines

RewriteRule info/([a-zA-Z]*)/ info/query.php?slot=$1

RewriteRule info/([a-zA-Z]*) info/query.php?slot=$1


in my .htaccess file for my query.php file it gives me the following errors.



Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://example.com/info/css/reset.css".

Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://example.com/info/css/style.css".

(index):27 Uncaught ReferenceError: $ is not defined



However, when i remove those two lines in the .htaccess file , there is no error and my script runs as expected.

What could be the problem ? What am i doing wrong that is causing such unexpected behavior?

Thanks!

If, anyone wants the query.php file , i can upload it as well.Please write in comments for the code.

Answer

The problem might be that you also 'rewrite' your CSS files. So they will also be processed by query.php. This is not what you want.

Try to restrict the rewrite rule to PHP files only like this:

RewriteRule ^info/(.*)\.php$ info/query.php?slot=$1

This will also do it for all file names, even if they are named something like: this_is_my_file.php.