简体   繁体   中英

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

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)

  <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 ! should i use absolute Links for my link tag in header.php ? like:

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

please help me tnx !

You must change paths by adding a slash in the begining.

When you access www.yourdomain.com/path1/

The server search files in 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">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM