modrewrite问题 - 404错误 [英] modrewrite issue - 404 error

查看:141
本文介绍了modrewrite问题 - 404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个网址

http://sites.com/driver.php?n=spa

我做了这个样子

I made it look like this

http://sites.com/driver/spa

在这里的.htaccess code,我使用..

here is .htaccess code I am using..

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^driver([^/]*)$ driver.php?n=$1 [L,QSA]

它的工作,但如我的所有文件,包括脚本和样式都没有工作,因为它增加了/驱动器的所有网址 像这样的例子

it's working but for instance all my files including scripts and stylesheets are not working because it's adding to /driver to all urls like this example

http://sites.com/style.css

http://sites.com/driver/style.css 

..我可以通过编写完整的脚本和样式表的URL避免的,但有没有其他办法?我能做到这一点,但我有40多个剧本和样式表的URL,它会带我的时间重写他们都用完整的URL。

.. I can avoid by writing the full script and stylesheet urls but is there any other way? I can do this but I have more than 40 script and stylesheet urls and it will take me time to rewrite them all with the full url.

推荐答案

这个问题的原因是使用的CSS / JS /图像资源的相对链接。要解决这个问题,你可以在你的页面的HTML头sdd的这样的:

Reason of this problem is use of relative links on CSS/js/image resources. To fix this issue you can sdd this in your page's HTML header:

<base href="/" />

本周告诉浏览器的追加/每个人都发现,在页面的相对路径的资源。

This week tell browser's to append a / everyone it finds a relative path resource in the page.

这篇关于modrewrite问题 - 404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆