tags:

views:

21

answers:

2

I used mode rewrite on my website

I used the base tag to solve my relative links problem

<base href="/" />

But the problem is absolute link eg. http://www.absolutelinks.com

It changes it to www.mysite.com/http://www.absolutelinks.com

How can i fix this

+1  A: 

Don't use <base> at all, instead have some server-side config and keep a $base variable there - then, when outputting any URL during your HTML generation use {$base}{$restofurl}.

This works well when you have the same code running in development/test/live environments - you just need to change your server-side $base config.

Using PHP/Smarty syntax above but I'm sure you get the idea.

Steve Claridge
+2  A: 

Base href applies only to the relative URL so if you have got: <a href="http://google.com/"&gt;Google&lt;/a&gt; you'll be redirected to Google, not http://mydomain/http://google.com/. Please post the code of your HTML document.

However using base isn't the best practice. Much better approach is to use absolute URLs like: src="/styles/main.css" which always points to mydomain/styles/main.css.

Crozin
but take care that if your website resides in a folder thhe "/style/main.css" wan't do it, e.g. http://www.mydomain.com/newtest/index.html, the src="/styles.main.css" will look for the css file in the root folder. I think the best practice is to use a config file to set the full path of your domain + path
Yehia A.Salam