Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
485 views
in Technique[技术] by (71.8m points)

.htaccess - mod_rewrite URL info required

I am new to this mod_rewrite. I have been successfully able to rewrite the URL something like this: http://mydomain.com/products/12 to this: http://mydomain.com/products.php?prodId=12

But when I give http://mydomain.com/products/12 in the address bar, the css and js files are not loaded.

But when I access http://mydomain.com/products.php?prodId=12 the js and css get loaded properly. Please let me know if I am missing something.

My .htaccess looks like this:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^products/([0-9][0-9])/$ /products.php?prodId=$1 [L]

My css and js folders are also in the same folder.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to know that relative URIs (thus absolute and relative URI paths too) are resolved from a base URI that is – if not explicitly declared – the URI of the current document.

So if you reference external resources from /products/12 with the relative URI foo/bar, it’s resolved to /products/foo/bar.

To fix this, use absolute URI paths (beginning with /) or absolute URIs (beginning with the protocol) or set explicitly a base URI other than the current (see BASE HTML element). But note that changing the base URI has some side effects as it affects every relative URI.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...