Welcome to WebmasterWorld Guest from 54.162.227.136

Forum Moderators: open

Message Too Old, No Replies

Dynamic meta tag depending on URL?

     
12:07 pm on Jul 18, 2012 (gmt 0)



Is it possible to have dynamic meta tag depending on URL?

Ex:

If i have www.example.com

<meta name="example" content="example">.

If it is home.example.com

<meta name="example" content="home example">

both URL redirects to same html page.

Please help
1:38 pm on Jul 18, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Perfectly possible. On a small site store the data in an array. On a big site use a database.

However, I have to ask 'where does redirecting come into things?' You're either serving a page or sending a redirect.
12:25 am on Jul 20, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I suspect he either means a rewrite or solves to the same page.

As g1smd says it is possibly, but will require some sort of server side scripting language. What scripting language is available on the web server.
6:44 am on Jul 20, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Ouch. If you're rewriting more than one URL to show the same content, you've got bigger problems than how to word the <meta> tag.

But yes, I think it can be done in about four lines of javascript, since that's where we are.
6:49 am on Jul 20, 2012 (gmt 0)



I have done using the below javascript

window.getSelection ? yourTag.name= ‘tagname' : yourTag.Name= ‘tagname '
yourTag.content='example.com';
document.getElementsByTagName('head')[0].appendChild(yourTag);
1:18 pm on Jul 20, 2012 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



That sounds like a very bad idea.
9:52 pm on Jul 20, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Do you mean the javascript itself or the rewrite?
1:18 pm on Jul 23, 2012 (gmt 0)

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



JavaScript is not the place to be doing this. What's the point of rewriting meta data about the document after you've already started serving the document? For one thing, those without JavaScript will end up getting different meta data (think about search engines). But even more importantly, if you've got home.example.com serving the same content (or nearly the same, if you take meta data into account), as example.com, then (as lucy24 pointed out) you're going to dilute the value of your content in the eyes of search engines.
12:53 am on Jul 24, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Which is why my original question to him was "What scripting language is available on the web server."
Client site scripting is not a good solution as Fotiman's pointing out.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month