1

I am trying to make clean urls for my website so i created a .htaccess file as following :

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^product/(\w+)/(\w+)$ product.php?id=$1
RewriteRule ^product/(\w+)/(\w+)$ product.php?id=$1

RewriteRule ^store/(\w+)/(\w+)$ Store.php?id=$1
RewriteRule ^store/(\w+)/(\w+)$ Store.php?id=$1

Now it works fine , but when i strat the page i see that the design is working with no css and no images , so what do you think is the problem ??

Best Regards

4
  • It depends on where your css and js files are. Use your browsers developer tools to see where the browser is looking for these files Commented Mar 8, 2013 at 12:36
  • I would say thet your first 2 rules might be braking the css. Try commenting them out and see what happens. Commented Mar 8, 2013 at 12:42
  • i trying to open this url : localhost/template/product/75/22 Commented Mar 8, 2013 at 12:47
  • and the browser is trying to find the css at Failed to load resource: the server responded with a status of 404 (Not Found) localhost/template/product/75/css/stylesheet.css Commented Mar 8, 2013 at 12:47

2 Answers 2

2

Problem is probably in relative path of your CSS file (and images etc). Use absolute path or base tag in header

<base href="http://www.example.com/" />
Sign up to request clarification or add additional context in comments.

4 Comments

i tried it and the browser is still trying to load it from Failed to load resource: the server responded with a status of 404 (Not Found) localhost/template/product/75/css/stylesheet.css when i try to open this url : localhost/template/product/75/22
And on your disc path {localhost_root}/template/product/75/css/stylesheet.css exists?
the css is in {localhost_root}/template/css/stylesheet.css
And product.php and Store.php are in localhost_root?
1

In the HTML page, prefix the links to your CSS files with /.

So, if you have:

<link rel="stylesheet" type="text/css" href="css/stylesheet.css" />

Change it to:

<link rel="stylesheet" type="text/css" href="/css/stylesheet.css" />

This make the path to the CSS absolute, so that it will find the CSS no matter what "folder" the browser thinks it is in.

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.