Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php重写引擎使用.htaccess不显示css_Php_Css_.htaccess_Mod Rewrite - Fatal编程技术网

php重写引擎使用.htaccess不显示css

php重写引擎使用.htaccess不显示css,php,css,.htaccess,mod-rewrite,Php,Css,.htaccess,Mod Rewrite,我使用.htaccess重写URL。请参见下面的示例: 我的文件夹是这样的: mysite(文件夹) css(文件夹) style.css mypage.php .htaccess 当我呼叫http://localhost/mysite/mypage/myid它被重定向到http://localhost/mysite/mypage.php?id=myid 问题是它似乎没有调用我的css,即: <link href="css/style.css" rel="stylesheet"

我使用.htaccess重写URL。请参见下面的示例:

我的文件夹是这样的:

  • mysite(文件夹)
    • css(文件夹)
      • style.css
    • mypage.php
    • .htaccess
当我呼叫
http://localhost/mysite/mypage/myid
它被重定向到
http://localhost/mysite/mypage.php?id=myid

问题是它似乎没有调用我的css,即:

<link href="css/style.css" rel="stylesheet" type="text/css" />
提前谢谢

编辑:

我尝试了以下解决方案:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
我仍然无法调用css:/

编辑2:

好的,我可以这样调用我的css:

<link href="/mysite/css/style.css" rel="stylesheet" type="text/css" />


看起来我还必须使用路径“/mysite/”调用html中的所有图像添加重写条件:

RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^mypage/([^/]*) mypage.php?id=$1

现在,您的css(以及其他文件和目录)将不会通过“重写规则”发送添加重写条件:

RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^mypage/([^/]*) mypage.php?id=$1

现在您的css(以及其他文件和目录)将不会通过重写规则发送

您需要告诉重写引擎忽略实际存在的目录和文件:

RewriteEngine on
RewriteBase /mysite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mypage/([^/]*) mypage.php?id=$1

您需要告诉重写引擎忽略实际存在的目录和文件:

RewriteEngine on
RewriteBase /mysite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^mypage/([^/]*) mypage.php?id=$1

你的造型现在被称为相对,所以你应该称之为绝对

没有/myid/css/文件夹,这就是您的代码现在要查找的内容

<link href="<?php echo $_SERVER['SCRIPT_URI'];?>css/style.css" rel="stylesheet" type="text/css" />

您的样式设置现在被称为相对,所以您应该称之为绝对

没有/myid/css/文件夹,这就是您的代码现在要查找的内容

<link href="<?php echo $_SERVER['SCRIPT_URI'];?>css/style.css" rel="stylesheet" type="text/css" />

该函数的结果应该写入吗?因为我在使用该函数时遇到php错误(windows Wamp srv上的im)。谢谢是的,在实时服务器上,它将回显当前页面的完整uri。但由于您是在本地主机上运行的,所以它不知何故不起作用。它应该是(http://)localhost/mysite/css/style.css.ok,所以我还必须添加这个函数,对吗?难道没有其他方法可以做到这一点吗?这个函数的结果应该是写的吗?因为我在使用该函数时遇到php错误(windows Wamp srv上的im)。谢谢是的,在实时服务器上,它将回显当前页面的完整uri。但由于您是在本地主机上运行的,所以它不知何故不起作用。它应该是(http://)localhost/mysite/css/style.css.ok,所以我还必须添加这个函数,对吗?难道没有别的办法吗?