Can I use canonical URL on the same page it links to? - url

I want to ask about canonical URL. Lets assume this URL structure:
/category_A/page1
/category_B/page1
/category_C/page1
Simply put, there are multiple URLs that display the same content. But only /category_A/page1 is original(canonical) page. My question is if it have any impact(bad/good/neutral) considering SEO if I will have canonical URL pointing to /category_A/page1 placed in this same page /category_A/page1 ?
The reason for this is, that its much easier to just put canonical URL into head of every page than to trying find out in which page it is not needed (its the same page as canonical one)

just do it
you described the perfect use case for the canonical tag. the canonical tag is a kind of failsafe against wrong URLs (or URLs with unnecessary parameters). so it's good to have it even on the page with the URL the canonical points to.

Related

Routing errors while processing URL(s) without a http prefix

We render HTML within a certain page and certain links don't have a http prefix (e.g. foo.com/bar) when you click on it throws a routing error. Is there a easier way to navigate to the right URL in such cases
Normally, the link_to takes care of you in this regard. You say html, so I assume we can't use ERB code, so you'll have to hardcode the links into the HTML.
Make sense?
Of course without any html code or routes.rb code, I can't tell you whether or not there isn't anything wrong with your existing code.
Why do you need to use absolute links within your application? Navigating to just "/bar" on that case would be fine.
If you use the link_to helper function on your views, it should rely on url_for which by default generates relative paths.
If you need absolute paths, you can specify a default host on your application (How do I set default host for url helpers in rails?) or specify it on the host option for the url_for function (http://apidock.com/rails/v3.2.13/ActionView/Helpers/UrlHelper/url_for).

URL redirection JSF

I have my my app url: 127.0.0.1:8080/reader/read.xhtml
The read.xhtml is populated thorough database and has got various
links which are hard coded in database. (read.xhtml is actually
retrieved as String from DB.) for e.g. there are links
(<a href ="/write.xhtml>write</a>)
/write.xhtml
/upload.xhtml
as I cannot add the context when i click the link it directs me to
WWW://127.0.0.1:8080/write.xhtml or
HTTP://127.0.0.1:8080/upload.xhtml
Is there any way I can redirect the link to
HTTP://127.0.0.1:8080/reader/write.xhtml.
Can Prettyfaces handle this. If yes how?
You can simply add the context path to the links by rendering it in front of your links. Something like:
write

A shorthand for multiple links?

I have a fairly long list of quick links (approx. 20) that I'm going to embed on my main page. Instead of adding the full url of each link to the each anchor, is there a way to add maybe the end of each link.
For instance, if the link to the url is
http://support.proboards.com/index.cgi?display&thread=423890
as you can see, my forum is a proboards forum if that helps anything here.
the location of each url is local,
Instead of adding the complete url, is there a way to use something like
<a href = "&thread=423890">
or maybe
<a href = "this.thread=423890"> ?
Not in pure HTML, the best you'll get is <a href="index.cgi?display&thread=423890">, which is what you should already be using. Of course I'm assuming support.proboards.com is your site here.
You could use JavaScript and call a function like openThread(423890) if you really wanted, but a)I wonder what you really gain from it, b)this won't work for people with JavaScript turned off (a la NoScript), and c)I wonder if Google would properly see all the links.
Presumably, these pages are all being generated by server-side script anyway, so you should only really be coding index.cgi?display&thread= once anyway...
If you're hard-set on doing something shorter, I'd suggest using URL rewriting. You can have a URL like .../display/thread/423890 and then use something shorter if you're already from a /display/thread/ page. But this requires the link to go to a page you have control over.

HTML Urls - how to append to the existing url

This is a stupidly easy question, however after searching for a long time I have yet to yield any results.
My question is as follows.
I have a webpage with the url http://domain.com/mypage/ladeda/
I have a link on this page.
Page 1
That link sends me to http://domain.com/1/
Page 1
That link takes me to http://domain.com/mypage/1/
How do i get my link to take me to http://domain.com/mypage/ladeda/1/
without having to extract all the aspects of the page url and put them within the href.
Many Thanks
<base href="/mypage/ladeda/" />
...
(goes to http://domain.com/mypage/ladeda/1/)
Via the <base> element.
But!
Page 1 should take you to http://domain.com/mypage/ladeda/1/ already provided that (a) you don't use a <base> element already and (b) the current resource is really http://domain.com/mypage/ladeda/ (with a trailing slash).
Page 1
If the current page isn't in the same directory (real or virtual) as the target page, you're going to have to specify a complete path. Either relative, or absolute. There's no way around it.

not having to encode url

Say I have this url "/my#stuff"
I am using asp.net mvc and when I try to goto this page it takes me to just "/my". The "#stuff" part has been removed.
Now I can get it to work fine if I encode the URL like so "/my%23stuff" since %23 decodes to #
However, is there a way I can get this to work without having to encode the url?
I'd like it if typing in "/my#stuff" as the URL worked just the same as "my%23stuff"
I don't think there is a way to do what you are saying. The hash is used in a URL for anchor tags.
You are pointing at a page /my and navigating to anchor tag "stuff" on that page. If anchor tag "stuff" does not exist it will just navigate to page /my.

Resources