我有一个脚本,使搜索我想要的结果也与查询访问
I have a script that make search and I want the results also be accessible with query
mysite.com/searchfor/"myword"
我说后面的行为.htaccess:
I added next lines to .htaccess:
RewriteEngine on
RewriteRule ^/?searchfor/(.*)$ search.php?search=$1 [L]
它的工作原理(加载页面时),但每一个链接的资源(CSS / JS)加载失败与下一个错误:
It works (the page is loading), but every linked resource (css/js) failed to load with next error:
Resource interpreted as Stylesheet but transferred with MIME type text/html
Resource interpreted as Script but transferred with MIME type text/html:
这些线参阅mysite.com/searchfor/theme.css~~V,但它是错误的,因为右链接到的CSS是mysite.com/theme.css
These lines refer to mysite.com/searchfor/theme.css, but it is wrong, as the right link to the css is mysite.com/theme.css.
我怀疑RewriteEngine叙述给错了路加载样式和脚本是什么失败了。 如何解决此问题?
I suspect RewriteEngine giving wrong path to load styles and scripts what failed it. How to solve this?
试试这个规则:
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]