在php中htaccess重定向url之后无法加载css和js

时间:2021-08-06 11:18:44

I am redirect my url using htaccess and i use this code in .htaccess file

我使用htaccess重定向我的URL,我在.htaccess文件中使用此代码

RewriteEngine On
RewriteRule ^mobile?$ index.php
RewriteCond ${REQUEST_URI} ^.+$
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$ [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]
RewriteRule ^product/([0-9]+)/(.*)$ product.php?c=$1&title=$2 [QSA,L]

and also add this code in product.php 
<head> <base href="http://localhost/asp/" /> </head>

That code in product.php file. I redirect successfully but can not load css and js in proper way. Can any one suggest to me how can i load css and js on product.php page.I can load image successfully but page design is not working correctly.I have search a lot of but not get proper answer please any one can provide the way or code which is helpful for me.

product.php文件中的代码。我成功重定向但无法正确加载css和js。任何人都可以告诉我如何在product.php页面上加载css和js。我可以成功加载图片但页面设计不能正常工作。我搜索了很多但没有得到正确的答案请任何人都可以提供方式或对我有帮助的代码。

2 个解决方案

#1


2  

As you know, the default bahavior of base is to replace the url(adress) before the relative adress. example:

如您所知,base的默认行为是在相对地址之前替换url(地址)。例:

<base href="http://www.mywebsite.com/images/" target="_blank">

The browser will look for the image "html5.png" at "http://www.mywebsite.com/images/html5.gif".

浏览器将在“http://www.mywebsite.com/images/html5.gif”中查找图像“html5.png”。

Hope it help you !

希望对你有所帮助!

#2


0  

Create a main folder then putt all the files in folder like thisenter image description here ...

创建一个主文件夹然后将所有文件放在文件夹中,如此处的图像描述...

#1


2  

As you know, the default bahavior of base is to replace the url(adress) before the relative adress. example:

如您所知,base的默认行为是在相对地址之前替换url(地址)。例:

<base href="http://www.mywebsite.com/images/" target="_blank">

The browser will look for the image "html5.png" at "http://www.mywebsite.com/images/html5.gif".

浏览器将在“http://www.mywebsite.com/images/html5.gif”中查找图像“html5.png”。

Hope it help you !

希望对你有所帮助!

#2


0  

Create a main folder then putt all the files in folder like thisenter image description here ...

创建一个主文件夹然后将所有文件放在文件夹中,如此处的图像描述...