473,409 Members | 2,022 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

anchors

To anyone who can help me, you have my thanks in advance.

I am implementing a "301 Moved Permanently" redirect in my website due to a
change of our domain names. Unfortunately, I am having a problem with
reconstructing the target "Location" http header because I'm missing just
one thing.

My links look as follows:

http://www.oldurl.com/beanie.php#thr...=false&demt=43

This I need to change to the following:

http://www.newurl.org/beanie.php#thr...=false&demt=43

As you can see, it's no BIG deal. All I need to change is the start and all
the rest can stay the same. So I need to create the new URL as a string so I
can call the following:

header("HTTP/1.1 301 Moved Permanently");
header($locationstring);
exit;

That's all.

First, I recreate the "server name" with the following two lines of code:

$oldurl = $_SERVER['HTTP_HOST'];
$newurl = str_replace("oldurl.com", "newurl.org", $oldurl);

Next, I can recreate the file name ("beanie.php") with the following line of
code:

$locationstring = ("Location: http://".$newurl.$_SERVER['PHP_SELF']);

Now I've got http://www.newurl.org/beanie.php.

The two GET vars "register" and "demt" I can access with

$registercode = $HTTP_GET_VARS["register"];
$articlecode = $HTTP_GET_VARS["demt"];

But how do I get the anchor!?!?!?!? How do I know if there was one and if so
what it was (the #three bit above).

Many thanks,

Ben.

Jul 17 '05 #1
7 2297
"Ben Wilson" <pl******@spam.com> wrote in
news:40***********************@news.skynet.be:
I am implementing a "301 Moved Permanently" redirect in my website due
to a change of our domain names. Unfortunately, I am having a problem
with reconstructing the target "Location" http header because I'm
missing just one thing.

My links look as follows:

http://www.oldurl.com/beanie.php#thr...=false&demt=43

This I need to change to the following:

http://www.newurl.org/beanie.php#thr...=false&demt=43
[snip]
But how do I get the anchor!?!?!?!? How do I know if there was one and
if so what it was (the #three bit above).


Unfortunately, you can't. Browsers don't send out fragment identifiers
when they make requests. If someone follows your old link, the browser is
going to ask the server for "beanie.php?register=false&demt=43" and, once
it gets a response, go looking for an id or named anchor called "three" in
the response.
Jul 17 '05 #2

"Eric Bohlman" <eb******@earthlink.net> wrote in message
news:Xn*******************************@130.133.1.4 ...
"Ben Wilson" <pl******@spam.com> wrote in
news:40***********************@news.skynet.be:
I am implementing a "301 Moved Permanently" redirect in my website due
to a change of our domain names. Unfortunately, I am having a problem
with reconstructing the target "Location" http header because I'm
missing just one thing.

My links look as follows:

http://www.oldurl.com/beanie.php#thr...=false&demt=43

This I need to change to the following:

http://www.newurl.org/beanie.php#thr...=false&demt=43


[snip]
But how do I get the anchor!?!?!?!? How do I know if there was one and
if so what it was (the #three bit above).


Unfortunately, you can't. Browsers don't send out fragment identifiers
when they make requests. If someone follows your old link, the browser is
going to ask the server for "beanie.php?register=false&demt=43" and, once
it gets a response, go looking for an id or named anchor called "three" in
the response.

Excellent! Then I don't even have to bother returning it! I can just forget
about it, for the browser will pick it up automatically! This exceeds my
expectations by far, by very far. In fact, it couldn't get any better. Thank
you,

Ben.


Jul 17 '05 #3
Ben Wilson wrote:

[ ... ]
http://www.oldurl.com/beanie.php#thr...=false&demt=43

This I need to change to the following:

http://www.newurl.org/beanie.php#thr...=false&demt=43
Cool, a dot com becomes a dot org; and "beanie"'s got me intrigued
too. But I can't access either. If those are examples, will you be
kind enough to post the actual URIs, please?

It's better to use the reserved TLD ".example" for examples (RFC2606).

[ ... ]
The two GET vars "register" and "demt"


Those URIs have no query components: there are no "GET vars". Did you
just write them wrongly here?

--
Jock
Jul 17 '05 #4

"John Dunlop" <us*********@john.dunlop.name> wrote in message
news:MP************************@News.Individual.NE T...

Cool, a dot com becomes a dot org; and "beanie"'s got me intrigued
too. But I can't access either. If those are examples, will you be
kind enough to post the actual URIs, please?

It's better to use the reserved TLD ".example" for examples (RFC2606).
Dear John:

Thank you for bringing RFC2606 to my attention. I am pleased to provide you
with the corrected URIs which I hope you will find less confusing:

http://www.oldhost.invalid/foo.php#t...=false&demt=43

http://www.newhost.invalid/foo.php#t...=false&demt=43

The two GET vars "register" and "demt"


Those URIs have no query components: there are no "GET vars". Did you
just write them wrongly here?

I'm sorry, I thought "register" was a GET var here equal to "false" and that
"demt" was a GET var equal to "43". Euhm, am I misunderstanding something?


--
Jock

Jul 17 '05 #5
"Ben Wilson" <pl******@spam.com> wrote in message
news:40***********************@news.skynet.be...

"John Dunlop" <us*********@john.dunlop.name> wrote in message
news:MP************************@News.Individual.NE T...

Cool, a dot com becomes a dot org; and "beanie"'s got me intrigued
too. But I can't access either. If those are examples, will you be
kind enough to post the actual URIs, please?

It's better to use the reserved TLD ".example" for examples (RFC2606).
Dear John:

Thank you for bringing RFC2606 to my attention. I am pleased to provide

you with the corrected URIs which I hope you will find less confusing:

http://www.oldhost.invalid/foo.php#t...=false&demt=43

http://www.newhost.invalid/foo.php#t...=false&demt=43
I can't stand the suspense... You don't have a query component because
you've put the anchor ahead of what you seem to think is the query string.
If you moved the anchor to the end where it belongs, you'll have a query
string (set of query parameters).
The two GET vars "register" and "demt"


Those URIs have no query components: there are no "GET vars". Did you
just write them wrongly here?

I'm sorry, I thought "register" was a GET var here equal to "false" and

that "demt" was a GET var equal to "43". Euhm, am I misunderstanding something?


yes... or so it seems.

- Virgil
Jul 17 '05 #6
Ben Wilson wrote:
http://www.newhost.invalid/foo.php#t...=false&demt=43
[ ... ]
I'm sorry,
No need to apologise!
I thought "register" was a GET var here equal to "false" and that
"demt" was a GET var equal to "43".
There is no query component here, no "GET vars" if you like, because
everything after the "#" is the fragment identifier and technically
not part of the URI. Besides, as Eric says, it's not even *given* to
the server; the user-agent keeps it and applies it to the retrieved
resource; as for text/html bodies, which presumably yours is,

| ... the fragment identifier designates the correspondingly named
| element; any element may be named with the "id" attribute, and A,
| APPLET, FRAME, IFRAME, IMG and MAP elements may be named with a
| "name" attribute.

RFC2854, "The 'text/html' Media Type",
http://www.ietf.org/rfc/rfc2854.txt

As Virgil Green has said, fix this by moving "#three" to the end:

http://www.newhost.invalid/foo.php?r...&demt=43#three

The query component is now "register=false&demt=43" and the fragment
identifier is "three".
Euhm, am I misunderstanding something?


I didn't elaborate on my apology for an explanation before because I
thought you just muddled up the parts of the URI references in your
article and wouldn't have appreciated it. Perhaps I was mistaken.

I'd still like to see the actual website! ;-)

--
Jock
Jul 17 '05 #7

"John Dunlop" wrote:
http://www.newhost.invalid/foo.php#t...=false&demt=43
[ ... ]
There is no query component here, no "GET vars" if you like, because
everything after the "#" is the fragment identifier and technically
not part of the URI. Besides, as Eric says, it's not even *given* to
the server; the user-agent keeps it and applies it to the retrieved
resource; as for text/html bodies, which presumably yours is,

| ... the fragment identifier designates the correspondingly named
| element; any element may be named with the "id" attribute, and A,
| APPLET, FRAME, IFRAME, IMG and MAP elements may be named with a
| "name" attribute.


Thank you (and Virgil) for your help. I understand what you are referring
to. The hypothetical URL I've taken here as an example is misformed.
Actually this is because there are no pages on the site that combine both
get vars and anchors. I realised for the pages that used get vars I could
reproduce the get vars by accessing the array, but for the pages that used
anchors I could not reproduce the anchors. I had never actually had to
implement both features at once.

I don't check out newsgroups often but I am surprised by everyone's interest
to see the website I'm working on. (Yes, the pages do have the extension of
asp but this is because we made a migration from asp to php and we haven't
gotten round to changing the extensions. That will be a next project.)

I will keep you in suspense no longer. An example of a page from our site
that uses getvars is

http://www.falconsoft.be/newsq.asp?article=325C5

An example of a page from our site that uses anchors is

http://www.falconsoft.be/careers!main.asp#02

All the best,

Ben.


I'd still like to see the actual website! ;-)

--
Jock

Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Jakobi | last post by:
Hello, I want to place two lines relative to another. The problem is, that these two lines are in different groups. Is there an possibility to set the x and y values of the second line with...
2
by: mlv2312 | last post by:
Hi, I have experienced problems when dealing with nested anchors. I implemented some code to perform highlighting and specific anchors are used for the searched words. The problem is when the...
1
by: mlv2312 | last post by:
Hi, I have experienced problems when dealing with nested anchors. I implemented some code to perform highlighting and specific anchors are used for the searched words. The problem is when the...
2
by: learner | last post by:
Hi, A document has many Anchors. I want to take a particular action only if some particular anchors are clicked. I mean if some anchors are clicked, i want an alert box to pop up with ok and...
21
by: adrian suri | last post by:
Hi just started to experement with styleshhets, and have defined hover a:hover { Color : red; Text-decoration : none; Border-top-width : medium; Border-right-width : medium;
12
by: Rich | last post by:
Strangely, on-page anchors will work on MSIE, but not on Netscape7.2 or Firefox1.5. All anchors are numbers e.g. <a href="#21">TOPIC</a> supposed to connect down to <a name="#21>beginning of...
17
by: Crimperman | last post by:
Hi, need some advice on URIs In a dynamic page (perl driven) we list a number of items presented in an hierarchical tree structure. Within that page is a form which allows you to search for...
1
by: Alec MacLean | last post by:
Hi. I'm using VS2005 Pro to work on a website project for my company. The site has several navigation elements, all based on the standard VS2005 navigation components. I have high-level...
3
by: windandwaves | last post by:
does it matter if I write var anchors = document.getElementsByTagName("A"); or var anchors = document.getElementsByTagName("a"); Or is there a better way to catch both <a hrefs and <A...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.