Michael Brenndoerfer
Michael Brenndoerfer

Reputation: 4066

Mod Rewrite to a non existent directory

my problem is, that if I rewrite my URL with following rule

RewriteCond %{QUERY_STRING} ^site=meine-bar&filter=([a-zA-Z]+)$
RewriteRule ^meine-bar/([a-zA-Z]+)$ index.php?site=meine-bar&filter=$1 [L]

my index.php also recognizes the new URL and my dependencies are wrong.

For example.

Normally the link would be for example

<link href="css/style.css" ... />

now that I've rewritten the URL the index.php looks for the link in meine-bar/css/style.css

How can I tell the Mod Rewrite to just "virtually" redirect me to this non-existent folder? I dont want to be in the folder (because it doesn't exist), I just wan't the user to believe that this folder exists (the URL just has to look like it exists)

Upvotes: 0

Views: 67

Answers (1)

Panama Jack
Panama Jack

Reputation: 24448

Change this

<link href="css/style.css" ... />

to this

<link href="/css/style.css" ... />

I believe it will still work as you need it to without meine-bar

The reason is you are using relative paths so it will pick up the directory the URL "thinks" it's in. To prevent that you need to use absolute paths. So by putting the / in front of the directory you are telling it to start at the webroot which is where you really want to be. Hope that makes sense.

Upvotes: 1

Related Questions