Php .htaccess重写url删除CSS、JS和图像无论我做什么都不起作用
我看过stackoverflow上的所有帖子,我所看到的都没有得到回复。 即时通讯使用:Php .htaccess重写url删除CSS、JS和图像无论我做什么都不起作用,php,.htaccess,url-rewriting,Php,.htaccess,Url Rewriting,我看过stackoverflow上的所有帖子,我所看到的都没有得到回复。 即时通讯使用: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !\.(?:css|js|jpe?g|gif|png)$ [NC] RewriteRule profile/username/(.*)/ profile.php?username
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(?:css|js|jpe?g|gif|png)$ [NC]
RewriteRule profile/username/(.*)/ profile.php?username=$1
RewriteRule profile/username/(.*) profile.php?username=$1
和im我的个人资料,php头im使用以下标记:
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo ucwords($profileData->first_name); ?> - Facebook</title>
<link rel="stylesheet" href="/assets/css/style.css" type="text/css">
<base href="index.php" />
-脸谱网
无论我做什么,它仍然不工作,请帮助 因为您正在重写规则,所以还需要重写base href HTML,或者只需将完整的url添加到样式、js和图像中。 示例库href:
<head>
<base href="https://www.yourwebsite.com/">
</head>
是的,我找到了发生这种情况的原因,非常感谢!我所做的使资产/。/。。进入测试/资产/....测试/资产/。。所以我把它们都放到了我的http:localhots/test/assets/。。现在它开始工作了!您必须小心,因为如果您创建了一个新规则,例如profile/username/activity,那么您需要再次移动它们../,如果您想更独立,只需尝试使用基本href或将完整url添加到href属性中即可。