invidious
invidious

Reputation: 241

htaccess rewrite messing up stylesheet and no trailing slashes

I'm such a noob when it comes to .htaccess, and can't figure this out.

.htaccess

RewriteEngine On
RewriteBase /tests/shop/

RewriteRule ^(recover/[a-zA-Z0-9]+)/?$ recover.php?code=$1 [NC,L]
RewriteRule ^(login|register|logout|benefits|loyalty|recover)/?$ $1.php [NC,L]
RewriteRule ^(rs|cs|ha)/?$ game.php?game=$1 [NC,L]
RewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ $1/ [NC,L]

When I go to the /recover/code/ directory as done in the 4th line, the stylesheet is completely missing due to it thinking the subdirectory is different.

This is how I include the stylesheet in my header file:

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

How can I fix this?

Also, how can I make the re-directs above all have trailing slashes? Where would I add the trailing slash to the code?

Upvotes: 0

Views: 347

Answers (1)

Jon Lin
Jon Lin

Reputation: 143876

Either change your links to be absolute urls or add a base to your page headers (between the <head> </head> tags).

Based on your rewrite base, I assume you'll want either something like this:

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

or

<base href="/tests/shop/" />

Upvotes: 1

Related Questions