0

I have the following base:

<base href="http://example.com:8080/en/" target="_self">

If locale is default then it becomes:

<base href="http://example.com:8080/" target="_self">

And I have logo image with root path

<a href="/"><img src="logo.jpg"></a>

The idea is when user clicks on logo he goes to main page. Main page can be requested or this way http://example.com:8080/ for default locale or this way http://example.com:8080/en/ for locale en.

However, when <base href="http://example.com:8080/en/" target="_self"> and user clicks on logo he goes to http://example.com:8080/ but not to http://example.com:8080/en/. Is it possible to set root path "/" according to base href?

Pavel_K
  • 10,748
  • 13
  • 73
  • 186
  • If you can change the content of the base href dynamically based on locale, then it should be no problem to change it for the link as well …? – CBroe Sep 02 '16 at 12:47
  • @CBroe Of course I can do everything with my html code. However, it is not the point of my question. Besides, base href is only in one place in html document and is generated, but the link to mainpage can be in several places and can be taken from DB! – Pavel_K Sep 02 '16 at 15:08

2 Answers2

0

Just provide attribute and don't provide a value. This would solve the issue.

<base href="http://www.example.com/en" target="_blank"></base>

<a href>Click Me!</a>
Nikhilesh Shivarathri
  • 1,640
  • 10
  • 16
  • When there is no / on the end the path is considered to be a file. See my answer and the link I provided. – Pavel_K Sep 02 '16 at 15:34
0

After reading very nice explanation here https://stackoverflow.com/a/29132586/5057736 I found solution -

<a href="./"><img src="logo.jpg"></a>
Community
  • 1
  • 1
Pavel_K
  • 10,748
  • 13
  • 73
  • 186