In URL rewriting, i am quite confused that should i use underscore (_) OR hyphen (-) to replace spaces. According to this and this, hyphen should be used.
But wikipedia uses underscores like en.wikipedia.org/wiki/Computer_network_programming. so which should be used?
use dashes
read from the matt's blog
http://www.mattcutts.com/blog/dashes-vs-underscores/
You can use whatever you want. It doesn't matter (from a technical point of view; there may be other reasons to choose one over the other).
Related
With restructured text, I've seen both these used:
`Some Link <http://www.some.com>`_
`Some Link <http://www.some.com>`__
Both generate the same output from Sphinx,
Whats the difference between using _ or a double underscore __ for http URL links?
Why would you one over another?
In short, if its a one-off (anonymous) URL which you don't intend to reference, use double underscore.
In practice you could use either in most cases, they generate the same HTML output for example.
However, using single underscores for links means that by default you're creating a reference target - which could conflict with other references of the same name.
So this for example will warn:
.. _Thing:
Title
=====
Text with `Thing <http://link.com>`_.
WARNING: Duplicate target name, cannot be used as a unique reference: "thing".
While this could be overlooked in most cases, it could make for confusing situations especially for anyone inexperienced with reStructuredText. So you may prefer to avoid this entirely only defining targets when that is your intention.
According to:
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#anonymous-hyperlinks
With a single trailing underscore, the reference is named and the same target URI may be referred to again. With two trailing underscores, the reference and target are both anonymous, and the target cannot be referred to again. These are "one-off" hyperlinks.
There are examples on the page links.
I would like to use underscore in my url instead of hyphen.
I mean like this wikipedia link
My Current url:
www.example.com/2013/01/hello-this-is-a-test-post/
Desired url
www.example.com/2013/01/hello_this_is_a_test_post/
But one good programmer in wordpress stackexchange advised me, Google treats - as word separator, but not _.
He also mentioned that rule doesn't apply for MediaWiki sites.
Is it true?
Google treats hyphens as word seperators is TRUE.
The reasoning behind it I recall is based on programmers searching for functions which usually (if not always) have underscores in them. So instead Google treats underscores as word joiners.
This article elaborates: http://www.ecreativeim.com/blog/2011/03/seo-basics-hyphen-or-underscore-for-seo-urls/
Markdown syntax for a link is pretty simple:
[Example](http://example.com/)
produces:
Example
But what if the link itself contains a closing bracket?
[Syntax](http://en.wikipedia.org/wiki/Syntax_(programming_languages))
produces:
Syntax)
which is obviously broken.
Edit
Putting the url in quotes does not work
Sometimes you need to encode ) with %29.
[Syntax](http://en.wikipedia.org/wiki/Syntax_(programming_languages%29)
E.g.: This was the only method I could find to get a correct Markdown preview in the Atom Editor.
You can try to escape the character:
[Syntax](http://en.wikipedia.org/wiki/Syntax_\(programming_languages\))
You can also encode the characters
[Syntax](http://en.wikipedia.org/wiki/Syntax_%28programming_languages%29)
The most reliable way I've found to do this is to use reference-style links instead of inline links.
Here is the wikipedia article on [Syntax][1]
[1]: http://en.wikipedia.org/wiki/Syntax_(programming_languages)
renders correctly as
Here is the wikipedia article on Syntax
I've found that with some sites, percent-escaping the parentheses will break URLs, especially anchors. For example, at least in my version of Firefox, this Android documentation link doesn't take me directly to the method with percent encoding.
But this one with a reference-style link does.
For example, at least in my version of Firefox, this Android documentation link
doesn't take me directly to the method [with percent encoding](https://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface%28java.lang.Object,%20java.lang.String%29).
But this one with a [reference-style link][2] does.
I have found that using < around > the url seems to solve the problem.
In the two internal systems we use that use markdown.
Your mileage may vary with other systems.
[Test](<https://en.wikipedia.org/wiki/Slowloris_(computer_security)>)
Test
Quoting w3Schools:
URLs can only be sent over the Internet using the ASCII character-set.
So, you need to encode any special characters that is not a ASCII character into its respective ASCII character.
In your case, the characters for brackets or parenthesis are
open bracket ( - %28
closing bracket ) - %29
You can use this website to get the encoded url of any website link.
You don't have to scape it at all.
On GitHub, I've just done the following without any problems:
[Slowloris](https://en.wikipedia.org/wiki/Slowloris_(computer_security))
Actually, even here you can use it directly, as you can see here.
Microsoft's reference doesn't say anything, but it seems that currentle everyone uses three dots (...) and not the unicode sign (…).
Is it OK, or maybe there are some guidelines I'm not aware of that recommend using the unicode sign?
I think it's safer to use three dots, because some fonts/systems might not interpret correctly the '...' single character.
I found this article regarding URL Rewriting most useful.
But here are a couple of questions.
I would love to use a URL (before rewriting, with spaces inside the query string)
http://www.store.com/products.aspx?category=CD s-Dvd s
First of all, should I replace the spaces with the plus sign (+) for any reason? Like this:
http://www.store.com/products.aspx?category=CD+s-Dvd+s
Secondly, my native language is Greek. Should I encode the parameters? Generally speaking, would the result with URL encoding on be different, regarding S.E.O.?
Actually you should replace spaces with hyphens. That actually is better for SEO than using an underscore.
If the value must come through unaltered, then yes you must use escaping. In a URL query parameter value, a space may be encoded as + or %20. mod_rewrite will generally do this for you as long as the external version was suitably spelled.
In the external version of the URL, only %20 can be used:
http://www.store.com/products/CD%20s-Dvd%20s
http://www.store.com/products.php?category=CD%20s-Dvd%20s
because a + in a URL path part would literally mean a plus.
(Are you sure you want a space there? “CDs-DVDs” without the spaces would seem to be a better title.)
It is non-trivial to get arbitrary strings through from a path part to a parameter. Apart from the escaping issues, you've got problems with /, which should be encoded as %2F in a path part. However Apache will by default block any URL containing %2F for security reasons. (\ is similarly affected under Windows.) You can turn this behaviour off using the AllowEncodedSlashes config, but it means if you want to be portable you can't use “CDs/DVDs” as a category name.
For this reason, and because having a load of %20s in your URL is a bit ugly, strings are usually turned into ‘slugs’ before being put in a URL, where all the contentious ASCII characters that would result in visible %-escapes are replaced with filler characters such as hyphen or underscore. This does mean you can't round-trip the string, so you need to store either a separate title and slug in the database to be able to look up the right entity for a given slug, or just use an additional ID in the URL (like Stack Overflow does).
General practice is to replace spaces with underscores, ala http://www.store.com/products.aspx?category=CD_s-Dvd_s