WordPress URL structure logic, how two different urls point to same content? - wordpress

I have noticed that after rewriting URL in a WordPress site, I can reach the same content using two URLs:
http://example.com/category/article-name-here/primary_key
as well as
http://example.com/category/article-name-here
Both of these URLs will point to exact same content. What is the exact logic behind it, is the article name is in itself unique?
I am creating a startup site which will have the same URL structure. But I cannot have same unique-article-name.

Check this article out:
http://codex.wordpress.org/Using_Permalinks
It says
In the Settings → Permalinks panel (Options → Permalinks before WordPress 2.5), you can choose one of the "common" structures or enter your own in the "Custom structure" field using the structure tags.

Wordpress uses something called a router, which is also part of many frameworks, particularly MVC frameworks, to determine what content to show based on the URL. For example, it might look up something in the database (e.g. old pages that have been renamed), then show the content based on that, or it might only look for a file on the server and then show a 404 page if it doesn't find it.
Basically, look into routing as it relates to PHP frameworks to see how that whole logic works.

Related

Set the permalink to any domain in Wordpress

Is this possible to achieve without too much effort or a plugin? It's simply to instantly redirect to a site I've made in my portfolio if the post doesn't have any content.
Note that I don't want a script in the actual post to redirect since I only use Wordpress as the backend and fetch all the data to be used by a JavaScript backbone app.
EDIT : Added some extra info in a comment
Short Answer: No. You cannot set your Post Permalink to an external asset without directly editing the database.
Long Answer: First off, you need to understand the purpose of the Permalink. It isn't just an arbitrary link to somewhere. It's reserved specifically for storing where that specific post lives within the context of your Wordpress installation.
Your post doesn't live on example.com. It has its own ID, and Wordpress has a specific spot set aside for it where it can be seen on YOUR domain. Leave it as such.
Instead, what you should be doing is employing the tools Wordpress gives you to achieve what you want. A Plugin doesn't exist for what you want because - quite frankly - it's a fairly trivial task when approached CORRECTLY and doesn't warrant the use of an external resource.
So what's the correct way?
Use a Custom Field. Name your Custom Field something like 'externalHref' and fill that in with your link to the website you want to point to in case there's no post content.
Then in whatever templates you're using to generate your posts, just check either for the existence of your Custom Field called 'externalHref' or check for the non-existence of Post Content. In either case, instead of generating a link using The Permalink you can simply build a link that points to wherever you need.

How difficult it is to redirect broken links based on keyword matching?

I currently host a blog on blogger under my own domain. The problem with blogger is that one cannot change the URLs. Page URLs contain "/p/", blog post URLs contain date (which don't even have to correspond to the actual publication date). If at some point I were to move to a self hosted solution and change the URL structure to something more user friendly, how would I redirect the broken links to new URLs, based on extracting the keywords from the old link? Does ASP.NET MVC offer an easy way to implement that?
I ask because I would like to stay with blogger for a little more, but wouldn't like to pay the price in the future.
Check out IIS Url Rewrite: http://www.iis.net/download/urlrewrite

Is this possible to give different links for the same wordpress blog?

I have developed a site using wordpress. I have two main links in the site e.g. www.mysite.com/siteone and www.mysite.com/sitetwo and I have managed only one blog contents. Now what I need to do is that I want to link the same blog with different link like this:
www.mysite.com/siteone/blog and www.mysite.com/sitetwo/blog and also need to have same content for links www.mysite.com/siteone/blog-1 and www.mysite.com/sitetwo/blog-1. Is it possible to do so, if yes then how to do that? If not then what can I do for that?
Thanks in advance
From the SEO perspective, it's wise to use canonical tag. This tag was a new construct designed explicitly for purposes of identifying and
dealing with duplicate content. Implementation is very simple and looks like this:
<link rel="canonical" href="http://www.yoursite.org/blog" />
This tag is meant to tell Yahoo!, Bing, and Google that the page in question should be treated
as though it were a copy of the URL http://www.yoursite.org/blog and that all of the link and
content metrics the engines apply should technically flow back to that URL.
The canonical URL tag attribute is similar in many ways to a 301 redirect from an SEO
perspective. In essence, you’re telling the engines that multiple pages should be considered as
one (which a 301 does), without actually redirecting visitors to the new URL (often saving
your development staff trouble).
link
The "home" link in a WordPress installation is determined by an option in the database called siteurl, so in theory you'll just have to use the same database on both blogs and override the siteurl on the two to make it seem like two different websites.
A good way to start from is define a constant in your wp-config.php, which should be different for both websites:
define( 'MY_SITE_URL', 'http://yoursite.com/siteone/blog' );
And then write a single-line plugin that would simply add a filter to the get_option call for siteurl. Something like this:
add_filter( 'option_siteurl', create_function( '$value', 'return MY_SITE_URL;' ) );
That's only the start, and if that works for you you'll have to then rumble around your wp-content directory to make sure they are in sync for both websites, i.e. after uploading an image to one blog you'll need to copy the file into the other one.
I did manage to get two different websites working under one WordPress installation using two different databases, but having two WordPress installations working line one site under two different domains, that's tricky ;)
~ K

WordPress - creating microsites

I have never used WordPress before but it seems to be the best package for user content sites.
I need to have a main site which has its own content but also be able to spawn microsites for a particular event.
These microsites will have around 10 pages and will use the same template and will need to have their content changeable.
In terms of url it would probably look a bit like this
main site - www.blog-x.com
microsite - www.blog-x.com/march-meetup/join
microsite page - www.blog-x.com/march-meetup/contact
Is this possible with WordPress ?
Thanks, Alex
If you by "use the same template" mean that the "microsites" should use the same layout and look like the main site, then see Shelly's answer above.
However, if you mean that you want these "microsites" to have different templates (but that the microsites' pages should use the same template), you're looking for the multi-site feature of WordPress. It will allow you to create new blogs (sites) in either subdirectories (blog-x.com/march-meetup) or on subdomains (march-meetup.blog-x.com). See WordPress Codex: Create A Network for details.
What you're talking about is simply adding Pages - not creating microsites. To get the URLs you want, all you'd have to do is create a new Page. (or even better, just create a category for each section, and post the relevant info to that category).
In other words, yes, it'll do what you want - but calling it a "microsite" is a misnomer.

Wordpress, two URLs for the same post

Is it possible to have two URL for a same post in wordpress.com?
One would be a short URL like
http://mydomain.com/28
and the other will be a SEO friendly one:
http://mydomain.com/28-this-is-the-post-about...
thanks
In wordpress, all posts are at the URL mywordpresshome.com/?p=xx where xx is the post ID number. Anything else involves mod_rewrite. WordPress will do one type of rewrite for you in the Admin section -- so you can pick either the short version or the long one above. In the Admin interface, it won't let you do both. But you could edit mod_rewrite yourself and effectively get both patterns -- short and long -- to work.
Here's info on mod_rewrite: http://www.workingwith.me.uk/articles/scripting/mod_rewrite
In the Settings->Permalinks part of the admin panel, you can set the look of your permalinks, but that doesn't mean the default dynamic links (yourblog.com/?p=5 or whatever) will stop working. You can use those links too and they will take you to the corresponding page. However, Wordpress will automatically substitute the dynamic link by its SEO-friendly alias.
I'm not sure whether it's possible to have two different aliases for the same post though.

Resources