简体   繁体   English

我更改.htaccess后,我的Css和Js无法正常工作

[英]After I Change my .htaccess my Css An Js not working

my project folders is like this 我的项目文件夹是这样的

  *myProject(d:wamp/www/mywebsites/myProject)
     @ ajax
     @ asset
        #all of php functions and database
     @ newsPicture
        #my post images
     @ profilePicture
        #user images
     @ public
       -js
       -css
       -img
       -.htaccess //file
       -index.php //file
       -User.php //file
       -Posts.php //file
     @ view
       -header.php  //include in index.php
       -footer.php  //include in index.php

so i set my htaccess to this 所以我将我的htaccess设置为此

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

#Change /Posts.php?id=4 => /Posts/4
RewriteRule ^Posts/([A-Za-z0-9]*)$ Posts.php?id=$1 [L]

#Change /User.php?id=4 => /User/4
RewriteRule ^User/([A-Za-z0-9]*)$ User.php?id=$1 [L]

#Change /Sign.php => /Sign
RewriteRule ^([A-Za-z0-9]+)$ $1.php [L]

and my html header is like this (view/header.php) 和我的html标头是这样的(view / header.php)

  <link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
  <link href="css/bootstrap-theme.min.css" type="text/css" rel="stylesheet">
  <link href="css/Normalize.css" type="text/css" rel="stylesheet">
  <link href="css/Fixer.css" type="text/css" rel="stylesheet">

so when i pass parametr in my url like User/2 all my css and js not working ! 所以当我像User / 2这样在我的URL中传递parametr时,我所有的CSS和JS无法正常工作! should i use absolute Links for my link tag in header.php ? 我应该为header.php中的链接标记使用绝对链接吗? like: 喜欢:

<link href="<?php echo dirname($_SERVER['PHP_SELF']);?>/css/Fixer.css" type="text/css" rel="stylesheet">

please help me tnx ! 请帮我tnx!

You must change paths by adding a slash in the begining. 您必须通过在开头添加斜杠来更改路径。

When you access www.yourdomain.com/path1/ 当您访问www.yourdomain.com/path1/

The server search files in www.yourdomain.com/path1 /css/bootstrap.min.css 服务器在www.yourdomain.com/path1 /css/bootstrap.min.css中搜索文件

<link href="/css/bootstrap.min.css" type="text/css" rel="stylesheet">
<link href="/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet">
<link href="/css/Normalize.css" type="text/css" rel="stylesheet">
<link href="/css/Fixer.css" type="text/css" rel="stylesheet">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我的 JS/CSS 滑块在第一张幻灯片后停止工作。 我该如何解决这个问题? - My JS/CSS Slider stops working after the first slide. How can i solve this? 添加 AOS JS 库后,我的自定义 CSS 过渡动画无法悬停 - My custom CSS transition animation is not working on hover after I added AOS JS library 为什么我的 CSS/JS 不能在 Github 页面上运行? - Why is my CSS/JS not working on Github pages? CSS 和 JS 不再在我的 Flask 应用程序上工作 - CSS and JS no longer working on my Flask app 我的 DIV 不能与我的 JS 动画正常工作,我应该怎么做? - My DIV is not working properly with my JS animation, What change should i do? 我的 CSS 和 JS 外部文件在我的项目中不起作用 - My CSS and JS external files are not working in my project 在我添加 chart.js 后,我的锚标签在我的网站中不起作用 - my anchor tags are not working in my website after i added chart.js in it 如何通过CSS和JS每隔15秒左右更改我的背景图像 - How Do I Make My Background Image Change Every 15 Seconds Or So Via CSS & JS 为什么当我尝试在滚动时更改它时我的旋转 css 不起作用? - why my rotate css isn't working when I try to change it while scroll? 当我使用 JavaScript 切换类时,为什么我的 CSS 可见性更改不起作用? - Why is my CSS visibility change not working, when I toggle class with JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM