Skip to content Skip to sidebar Skip to footer

Rewrite Engine .htaccess Mime Type Error

I have a script that make search and I want the results also be accessible with query mysite.com/searchfor/'myword' I added next lines to .htaccess: RewriteEngine on RewriteRule

Solution 1:

Try this rule:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !\.(?:jpe?g|gif|bmp|png|tiff|css|js)$ [NC]
RewriteRule ^/?searchfor/(.+)$ search.php?search=$1 [L]

Solution 2:

I suspect RewriteEngine giving wrong path to load styles and scripts what failed it.

Not the RewriteEngine is giving the wrong paths – your HTML is.

If you refer your scripts and stylesheets relative to the path the client has requested, then it of course make a difference whether the client requested example.com/foo or example.com/searchfor/bar – since relative paths are resolved in relation to the location of the current document.

How to solve this?

The easiest way is to reference external resources relative to the domain, beginning with a slash – instead of script.js you use /script.js, that tells the client that he has to complete this path with the domain only.

Post a Comment for "Rewrite Engine .htaccess Mime Type Error"