I've set up a brochure ware kind of site - with links to different sections in the page.
http://www.leoniepalmer.com/
When clicking a menu item in the top right corner, everything works great!
Now I have a second page at
http://www.leoniepalmer.com/our-gourmet-tours/
And I want the menu to then go back home to the relevant anchor, that is, clicking About will go to
http://www.leoniepalmer.com/#about
Unfortunately (in FF 3.5.6 at least), it seems to append it to the URL and it becomes quite ugly, as well as not going to where it should!
Could it be this rule in my .htaccess, that appends a trailing slash to pages without one?
# Add trailing slash if missing
rewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ $1/ [NC,R=301,L]
How could I modify it to work, or is there something else at play here?
UPDATE
I don't think the answer is helpful at all.
You can link to an Id using the #anchor fragment.
OK, I'm guessing it's because you're using a <div> tag as the target of a link.
Properly, named tags that are the target of links to a location in a page are also <a> tags, your syntax is similar to
<a name="about">About Leonie and Stef Palmer</a>
Here's the source:
source
This creates an anchor around the text "This is the location of anchor one.". Usually, the contents of A are not rendered in any special way when A defines an anchor only.
Having defined the anchor, we may link to it from the same or another document. URIs that designate anchors contain a "#" character followed by the anchor name (the fragment identifier). Here are some examples of such URIs:
An absolute URI: http://www.mycompany.com/one.html#anchor-one
A relative URI: ./one.html#anchor-one or one.html#anchor-one
When the link is defined in the same document: #anchor-one
Just to be safe, you might want to make the link in your navbar to the full document:
About
Not only is this one of the use cases described above, it saves Apache some work. Including the full path lets the browser go straight to the page, whereas not including the name of the document means the browser has to ask Apache on your server what the name of the page is and then go there - 2 connections for the price of 1
Related
I am running wamp on my pc, with more than one project, so in order to go to my project I need to go to localhost/project1 and it works fine however href links (/mypage.html) keep pointing to localhost/mypage.html.
What do I need to change in order to keep the links in my project path?
First of all it is always better to create different virtual hosts Please refer this link to do the same https://www.kristengrote.com/blog/articles/how-to-set-up-virtual-hosts-using-wamp
OR
use href links as (mypage.html) or (./mypage.html) which will add mypage.html to your last trailing "/" in url
Use an absolute link in the form of href="/project1/mypage.html" or use a relative link of the form href="mypage.html" or href="./mypage.html".
A link with a leading slash is usually interpreted as an absolute link, beginning from the server's root.
In contrast, omitting the slash links relatively. A leading dot with a slash makes this even more explicit, saying "relative to the current path".
See also this SO post for a more detailed explanation.
original url
http://wwww.mydomain.com/image.php?id=13&cat=4&type=3$date=2011-03-14
i want to modify this dynamic url to something like this
http://www.mydomain.com/imageid/imagetitle (no php/html extension at the end )
plz if someone could help me in this , i have tried several online generators but my modification is little different.
I don't know how to write mods .
well, to get it you could need a page that redirects you to another location.
in the head section of your html page you have to specify a meta tag like it:
<meta http-equiv="refresh" content="0; http://www.mydomain.com/imageid/imagetitle" />
when you land on that page, it counts to seconds you specified in the first argument of content (in this case 0 seconds) and opens the new page passed as the second parameter.
a easy thing you could do to avoid extensions to be visible on the address bar of your browser is to create a folder in your web server (in your case "imagetitle") and put inside it an index page for example "index.html" which is the page loaded by default when a user aims to that link
I need to show on the address bar just the first part of the url of my site.
For example for any page with name like
http://www.mysite.com/mypage.php or
everything else
I want to see just http://www.mysite.com on the address bar of the browser.
How this can be achieved?
I tried with apache RewriteRule but with no result.
Apart from being a really bad idea for people actually trying to use your site, there is no way you can do this on the server side, because the server needs to know which page was accessed - that's what a URL is for. What you are looking for is to make it appear to the user that they are still at the same URL.
This is easy enough if you put your entire site in an HTML frameset with one frame, or an iframe sized to fill the browser window. This does require all external links to have target="_top", and without additional JS people can break out of the frame and access the pages individually anyway.
An alternative approach, that will only work on some browsers, would be to use history.pushState to fake the address bar back to / every time a new page loads.
We have some generated pages whose URLs contain parameters, like http://example.com/page.do?param1=hello. These pages contain named anchors inside, <a name="here">like this</a>. And there are corresponding links that reference the named anchors, like this. Most folks today call these "skip links".
Clicking a skip link should result in the browser creating and following a URL that matches the original one, with the named anchor tacked on at the end: http://example.com/page.do?param1=hello#here
On Firefox and IE, this works fine. On Chrome, Safari and other WebKit-based browsers, the parameters are lost, leading to http://example.com/page.do?#here which is invalid for our site, and just causes a 404 error.
Interestingly, if you manually put the full link in the location bar and press Enter, it behaves properly.
I've googled around a while and seen a lot of discussion about WebKit having problems with skip links, but none of them match the situation here where it's losing parameters.
Is this loss of parameters a known bug? Has anyone seen a workaround?
I encountered the same issue. From what I can say this is related to the usage of a meta tag like this: <base href="http://example.com" />. Once it is set my links point to example.com#foo instead of example.com?foo=bar#foo.
Knowing that I found this question. So the anchor tag behavior is a known thing:
Is it recommended to use the <base> html tag?
Since I can't remove the base tag I'll try to handle this with JavaScript.
So I'm working with WebKit's - WebView and WebFrame. I use a custom NSURLProtocol to retrieve the HTML for each request from a database. The problem arises from the fact that the links in the HTML are all relative, when they really ought to be absolute. For example, the page
foo/bar.html
May have a link in it that points to
foo/baz.html
The problem is that since the link is relative, the request ends up being for
/foo/foo/baz.html
So far, I've tried to work around this by comparing the two URLs and stripping off the common prefix - in this case 'foo/' - leaving me with foo/baz.html. This doesn't work for all possibilities, however, especially when there are multiple directories in the path. I do this in the "didStartProvisionalLoadForFrame:" method of my WebView's frameLoadDelegate.
Unfortunately, I do not have control over the HTML that I'm displaying, so modifying the links themselves is not an option.
Try being the main frame's resource load delegate, and implementing webView:resource:willSendRequest:redirectResponse:fromDataSource: to modify the URL being requested. Send relativeString to the request's URL to get the original relative URL, then use -[NSURL initWithString:baseURL:] to create a new URL with the same relative string against the correct base URL.