mod_rewrite的VS相对路径 [英] mod_rewrite VS relative paths

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

问题描述

我的mod_rewrite code是:

My mod_rewrite code is:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)?$ index.php?url=$1 [L,NC]

此结构放置我的服务器路径

This structure is placed on my server path /beta

当我把 http://mydomain.com/beta/download 一切正常重写的真实路径URL 的http:// MYDOMAIN的.com /测试/的index.php?URL =下载

When I place the URL http://mydomain.com/beta/download everything works rewriting to the real path http://mydomain.com/beta/index.php?url=download

问题发生的相对路径。当我输入网址 http://mydomain.com/beta/download/box 重写去 http://mydomain.com/beta /index.php?url=download/box ......但是......

The problem happens with the relative paths. When I enter the URL http://mydomain.com/beta/download/box the rewriting goes to http://mydomain.com/beta/index.php?url=download/box... but....

我所有的相对路径,像我的css文件夹中,我的js文件,图像文件....一切都在我的index.php页面崩溃的相对路径的辩论,因为我的相对路径成为下载/ CSS 下载/ JS 下载/图片 ...等...

All my relative paths, like my css folder, my js folder, image files.... everything with relative path in my index.php page crashes, cuz my relative paths become download/css, download/js, download/images... etc...

我知道原因在路径下载/,但如何解决使用了mod_rewrite在.htaccess?

I know this problem happens in reason of the slash in the path "download/", but how can I solve that using the mod_rewrite in .htaccess?

我可以prevent在相对路径重写?甚至在我自己的域的内部路径?

Can I prevent rewriting in relative paths? Or even in internal paths of my own domain?

我该如何解决,如果没有改变我的相对路径绝对路径?

How can I solve that WITHOUT change my relative paths to absolute paths?

感谢

推荐答案

添加<基地HREF =yoururl.com/beta/; /> 标记你的HTML头。另外补充的RewriteBase /测试/到htaccess的,如果你在该子文件夹是

Add a <base href="yoururl.com/beta/"; /> tag to your HTML head. Also add RewriteBase /beta/ to the htaccess if you're in that subfolder

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

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