.htaccess-url:重写本地主机Xampp上丢失的css javascript和图像文件


.htaccess url: rewrite missing css javascript and images file at local host Xampp

我是.htacees的新手。我正在尝试使用模式重写为用户制作用户友好的URL。我的问题是,当我使用.htaccess re:write打开"user.php"页面时,它无法加载CSS文件图像文件

Sign up
My account
Hi
    My Profile
    My account
    Logout
    Help
    © 2014 Company, Inc.

我有一个类似的链接:

http://localhost/www.zeeshan.com/user.php?name=zeeshan06

新的链接是类似的东西,它的工作100%对我来说是正确的。

http://localhost/www.zeeshan.com/user/zeeshan06

我的.htaccess文件

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /www.zeeshan.com/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^user/([^/]+)$ user.php?name=$1 [NC,L]

我的CSS文件路径CSS/style.CSS,CSS/bootstrap.CSS,bootstrap.min.CSS,位于www.zeeshan.com文件夹中

<head>
<link href="style.css" rel="stylesheet" type="text/css"/>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css"/>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>

使用out.htaccess页面可以很好地显示div、panel等的cssre:write-its无法打开css文件图像文件

CSS文件的路径是相对的。因此,当您加载http://localhost/www.zeeshan.com/user/zeeshan06时,浏览器正在名为http://localhost/www.zeeshan.com/user/的文件夹中查找CSS文件。您需要将路径更改为:

<head>
<link href="/www.zeeshan.com/style.css" rel="stylesheet" type="text/css"/>
<link href="/www.zeeshan.com/css/bootstrap.css" rel="stylesheet" type="text/css"/>
<link href="/www.zeeshan.com/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
</head>

如果在<base>标记内的每个页面上都放置了一个静态链接,则需要在部署后再次对其进行更改。

使用这个:

<base href= "<?php echo "http://".$_SERVER['HTTP_HOST']."/your_folder/" . "/>" ; ?>"

这样你就可以上传到生产中,再也不需要更改了。