What are the recommendations for html <base> tag?

前端 未结 17 2250
一向
一向 2020-11-21 10:17

I\'ve never seen HTML tag actually used anywhere before. Are there pitfalls to its use that means I should avoid it?

The fact that I have never noticed

17条回答
  •  囚心锁ツ
    2020-11-21 10:32

    Well, wait a minute. I don't think the base tag deserves this bad reputation.

    The nice thing about the base tag is that it enables you to do complex URL rewrites with less hassle.

    Here's an example. You decide to move http://example.com/product/category/thisproduct to http://example.com/product/thisproduct. You change your .htaccess file to rewrite the first URL to the second URL.

    With the base tag in place, you do your .htaccess rewrite and that's it. No problem. But without the base tag, all of your relative links will break.

    URL rewrites are often necessary, because tweaking them can help your site's architecture and search engine visibility. True, you'll need workarounds for the "#" and '' problems that folks mentioned. But the base tag deserves a place in the toolkit.

提交回复
热议问题