Sef URL CSS问题

I try to create Search Engine Friendly URLS like this;:

RewriteRule ^m/([0-9]+)$ my.php?id=$1

However, it gets the page without CSS.

If I write like this:

RewriteRule ^([0-9]+)$ my.php?id=$1

it gets the page with CSS without any problem.

How can I solve it?

When you write CSS references like this:

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

it's a relative URL. On http://example.com/, that points to http://example.com/style.css, but on http://example.com/my/1 it points to http://example.com/my/style.css, which doesn't exist.

Using an absolute URL fixes this:

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

This can be fixed by adding a base attribute to the head tag of each page:

<base href="http://www.example.com/" />

or add / before the css.

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

What was happening was that when you were redirecting the page, it was also looking for the css in my/css instead of css adding the above will fix that.