相对路径css/js的mod_rewrite问题 [英] mod_rewrite problem with relative path css/js

查看:84
本文介绍了相对路径css/js的mod_rewrite问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有问题. 我想获得所有重定向到主目录中索引文件的请求,并且已经实现了这一点,但是相对路径存在问题.
当我输入如下地址:mydomain.com/something时,它的工作正常,因为路径是相对于主目录的.
问题是当我输入如下内容时:mydomain.com/something/somethingelse.

Hi I have a problem. I want to get all requests to redirect to index file in main directory and I've achieved this but there are problems with relative paths.
When I put address like: mydomain.com/something it works ok as the paths are relative to the main directory.
The problem is when I put something like: mydomain.com/something/somethingelse.

.htaccess文件:

the .htaccess file:


Options FollowSymLinks
RewriteEngine On
# ignore anything that's an actual file
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
# redirect all other traffic to the index page
RewriteRule . index.php [L]

关于如何使css/js工作的任何想法?

Any ideas on how to get css/js working?

问题在于,当输入的路径具有多个斜杠时,不会加载css/js文件
like:mydomain.com/something/somethingelse

The problem is that css/js files aren't loaded when the path entered have multiple slashes
like:mydomain.com/something/somethingelse

推荐答案

无疑,对静态文件(css,js,图像等)使用绝对路径无疑会更好.但是,如果您在多个页面中都有大量实例,则可以考虑使用 HTML基本标记来指定一个相对路径的默认URL.例如:

It is no doubt better to use absolute path for static files (css, js, images etc). But if you lots of those instances in several pages then consider using HTML base tag to specify a default URL for relative paths. eg:

<base href="http://www.example.com/static/" />

这篇关于相对路径css/js的mod_rewrite问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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