Apache: Realative Link Problem using Rewrite Engine (mod_rewrite)

Using the Apache Rewrite Engine there might occour a problem with relative links if you are e.g. are jumping between directories or if you are using the the Rewrite Engine for an internal proxy. In the follwing example realtive links in the page will not work properly.

  <Directory "/documentroot/de">
  RewriteEngine on
  RewriteBase    /de/
  RewriteRule    ^/?  http://localhost/?language=de  [P]

There is a very easy solution to avoid this problem. You can define a base url tag in the header section of your HTML pages.

In the example above you have to include something like follows to the header section of all pages that do not work properly:


<head>
   <base href="http://localhost/">
</head>

 

That’s ist!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: