Reputation: 3
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 !
Upvotes: 0
Views: 87
Reputation: 1120
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">
Upvotes: 1