htaccess CSS图像 [英] htaccess css images

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

问题描述

我搜索了所有类似的问题并失败了:

I've searched all similar questions and failed:

我写了一个类似于zend Framework(PHP)中实现的URL重写:

I wrote a url rewrite similar to the one implemented in zend framework (PHP):

localhost/user/new

调用名为 UserController 的控制器,并执行功能 NewAction

Calls for a Controller Named UserController and executes a function NewAction. Works like a charm.

但是 $ _ GET $ _ POST有一些问题和图片,我猜这是因为htaccess文件。它是这样的:

But I have some problems with $_GET, $_POST and Images and I guess it's because of the htaccess file. It goes like this:

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

我使用jQuery ui和jQuery UI在CSS中使用相对链接。

I use jQuery ui and jQuery UI uses relative links in its CSS.

如果我做这样的事

http://localhost/login

图像加载正常,一切正常。

the images load fine and everything works.

如果我添加一个斜杠,例如 http:// localhost / login / http:// localhost / login / param1 ,就会加载映像,但也会调用控制器:

If I add a trailing slash like http://localhost/login/ or http://localhost/login/param1, the image gets loaded, but the controller gets called, too:

http://localhost/login/param1/images/ui-bg_glass_75_e6e6e6_1x400.png

我不知道如何解决此问题。邮寄和付款还有待解决的问题通过表单获取,但是我想这可能是相关的,所以我只想清除它。

I don't get how to correct this. There is also a pending problem with post & get via forms, but I guess that this maybe related, so I just want to clear this.

非常感谢!

推荐答案

让我解释一下:

RewriteCond%{REQUEST_FILENAME}!-f 检查是否尝试加载服务器上不存在的文件, RewriteCond%{REQUEST_FILENAME}!-d 检查是否尝试加载服务器上不存在的文件。服务器上实际上不存在的目录。

the RewriteCond %{REQUEST_FILENAME} !-f checks if you try to load a file that does not really exist on your server, RewriteCond %{REQUEST_FILENAME} !-d checks if you try to load a directory that does not really exist on your server.

因此,如果您尝试加载不存在的文件,则会将其重定向到index.php。

so if you try to load a file that does not exist it is redirected to index.php.

如果您的网址是 http://localhost/login/param1/images/ui-bg_glass_75_e6e6e6_1x400.png,则目录中必须存在名为ui-bg_glass_75_e6e6e6_1x400.png的图像该文件位于名为param1的目录中,该目录位于您的服务器根文件夹中的名为login的目录中。如果没有这样的目录结构或图像,则请求ist发送到index.php

if your url is 'http://localhost/login/param1/images/ui-bg_glass_75_e6e6e6_1x400.png' then there must be an image named ui-bg_glass_75_e6e6e6_1x400.png in a directory calles images which lies in a directory called param1 which lies in a directory called login which lies in your server-root-folder. if there is no such directory structure or image then the request ist send to index.php

如果要加载图像images / ui-bg_glass_75_e6e6e6_1x400.png然后不要放

if you want to load the image images/ui-bg_glass_75_e6e6e6_1x400.png then dont put the login/param1 before it.

也许使用绝对链接包含jquery-css即可解决您的问题。

maybe including the jquery-css using an absolute link will solve your problem.

<link href="http://localhost/jquery-ui.css" type="text/css" rel="stylesheet">

然后,css文件中的相对链接将相对于该链接标记中指定的路径。

then the relative links in the css file will be relative to the path specified in that link-tag.

这篇关于htaccess CSS图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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