Reputation: 1495
I have a .htaccess file with the following:
RewriteEngine On
RewriteRule ^product/(.+)$ /product.php?name=$1 [L]
This basically looks for "product/" within the URL and redirects to product.php
product.php is in the root folder: eg. mywebsite.com/product.php and when loaded directly looks fine and all CSS works.
However when I go to mywebsite.com/product/example-product the redirect to product.php works, but the CSS is lost (It's in a seperate stylesheet).
I do not have a product directory, is this why the CSS won't load? Is it possible to have directories in the URL yet redirect to a file in the root folder?
Ideally, I'd like the following:
mywebsite.com/product/example-product
redirects to
mywebsite.com/product.php?name=example-product
I hope that makes sense.
Upvotes: 0
Views: 65
Reputation: 8047
All you need to do is set a base
tag in your HTML head
. For example:
<base href="http://www.website-example.com">
Upvotes: 1