0

When i was trying to rewrite url using .htaccess i got my page css disturbed. i don't know why that happened. Anyone please help..

RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ index.php?$1=$2 [L,QSA]

here is the example Without rewriting url

with rewrite rule

2

2 Answers 2

1

Your CSS source is relative to the current document.

Make sure, its an absolute URL.. since

in case of rewrite, its requesting, field/stylesheets/style.css instead of stylesheets/style.css

your css source should be :

<link href="http://[yoururlhere]/stylesheets/style.css" media="all" rel="stylesheet" type="text/css" />
Sign up to request clarification or add additional context in comments.

4 Comments

should i give all links absolute eg. for javascript files etc.
Yes, thats the best practice.
is there any way to give links relative to root ??
No, if you want to reference a file from the root of your webserver it must start with /. Using a dot before the slash ./ makes the reference relative to the current html document. Also see here
0

Your paths are broken. Give the absolute path for the css and put one .htaccess file in css directory with only

RewriteEngine Off

in it

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.