Consider this link
https://meta.stackexchange.com/questions/21657/what-did-the-original-stack-overflow-look-like
As you can see this is a link to a StackExchange page. This has a pattern in it like www.websitename.com/title_of_the_page. How does this link open up a answer page? Is there a folder called title_of_the_page or how to write a PHP script that can get this title_of_the_page from the link?
No there is not any folder called the title of the page and should not be. It's all about rewrite rule. The number you are seeing in the link is the actual id of the question which is the main thing in the url. If you only use the id like
https://meta.stackexchange.com/questions/21657
it gets redirected to the original url. Consider reading this article:
https://www.tinywebhut.com/redirect-all-urls-to-proper-version-of-urls-38
Moreover, this is the best practice for Search Engine Optimization(SEO).
Related
Sorry for the title as I really have no idea what to call this.
Though with the template i've got it has links of like: index.php#home [it takes me to the class id of "home" instead of reloading an actual full page. Anyways i'm intergrating a script into it which has a blog. and for the blog its link is view.php?id=1
Anyways my panel I want it to take me is called blogp though in blogp it reads the url and finds out the id example index.php?id=1 and it takes me to the blog post with the id 1. I'm just wondering how I'd do it now that i'm using #blogp
My attempts:
index.php#blogp&id=1
index.php#blogp?id=1
But none work.
I have a Joomla! website with rewrite rules activated. My article URl is mysite.com/category/ID-alias.html. The only thing which is important (from this url) is the id, because when I can access the article with any text at "category" and any text at "alias".
Let's show a concrete example:
My article URL: mysite.com/flowers/15-begonia.html
I can access the same by changing category name and alias directly from url:
mysite.com/tralala/15-anything.html //Shows the same article as above.
Is this SEO? If one of my visitors want to destroy my website SEO, can he open my articles with different addresses (like above) and Google will say that articles are duplicated? Does Google knows when a visitor goes to a webpage to which link doesn't exists anywhere?
Hope my question is clear.
Thanks.
Google do a good job of deciding which is the "right" version of a page - it is worth watching this video to see how they handle this situation:
http://www.youtube.com/watch?v=mQZY7EmjbMA
Since these wrong URLs should not be linked to from anywhere, it is unlikely they will be indexed by mistake.
However, should they index the wrong version of a page, setting a sitemap with the right one will usually fix it.
A visitor could not harm your SEO with this knowledge. The worst they could do would be to provide good links to a non-indexed page, which would cause the wrong URL to be indexed. However, it would then be very easy for you to 301 redirect that page and turn their attempts at harm into an SEO benefit.
I personally think Joomla should look into adding the canonical tag, but if you want that currently, you must use an extension like this:
http://extensions.joomla.org/extensions/site-management/seo-a-metadata/url-canonicalization-/25795
(NB I have never used this extension so cannot guarantee its quality - the reviews are good, though)
My site has pages like news.php, vidoes.php, products.php etc
The data for these pages are held in a MySQL database they have id, name, description and permalink
If a name is News Article Title or Boxing Match Video they permalinks would be news-article-title and boxing-match-video
Now on the news.php page there is a list of news articles and they are linked to read-news.php with ?id= and the article id beside it.
So a link looks like this www.mysite.com/read-news.php?id=2
On my read-news page I use a GET to get the id and then data for that article comes too.
How do change the links on the news.php page to come up as www.mysite.com/read-news/news-article-title.php and the URL to display the same when reading it.
I cant seem to find a tutorial that shows exactly what I need.
Any help please
Thank you
You have to use a .htaccess file (if you are on a Apache server and do not have access to the server itself, like in a shared hosting situation)
.htaccess is a simple textfile you make and place in the directory in which it controls the access, e.g. the redirection of URL's and has a lot of usable functionality.
With this you can have your URL's rewrited without the user noticing it.
Good for SEO purposes.
More info: http://httpd.apache.org/docs/current/mod/mod_rewrite.html
If you want a quick try, automatic generation is done at
http://www.webconfs.com/url-rewriting-tool.php
I'm trying to make the URLs of my site SEO and user friendly. It is basically a static corporate website but for the side menu I am passing some variables through URL to show the sub menu of main selected menu.
For example: Offshore staffing is one of the main menu items and one of its sub menu items is Programmers. When someone clicks Programmers I will pass the id of main menu and sub menu through URL to collapse all other menus and promote the opened menu.
I want to mask something like ?id=4&sid=4 at the end of every URL. Can't use hidden input element because I am modifying this site and the developer who actually built that site didn't use forms.
You're looking for using a .htaccess file to rewrite URL's. For example stackoverflow might use something like this:
RewriteEngine on
RewriteRule ^questions/([0-9]+)/([_\-\&\'\,\+A-Za-z0-9-]+)?$ questions.php?q=$1
This would make both stackoverflow.com/questsions/1234/a-title-of-a-page and stackoverflow.com/questions.php?q=1234 the same page, so on your website you would need to use the "tidy" version of the URL (the first one)
A lot more can be read into this and you can customize you're URL's to what you require. For example, a few places to read up on it include:
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
http://www.easymodrewrite.com/
Generally a good way to do this (so that you don't have lots of ID's in your URL's) is to store a "URL friendly" name of the page (e.g. "name-of-page") in your database, then when the page is requested, just search your database for that name and you'll know what ID it relates to.
Translate the ID's to the words they stand for when writing the links, and use mod_rewrite to pass them back to PHP when they're visited, where you do a lookup based on the words, and find the ID again.
So the link becomes /offshore/programmers, then you do a lookup for the ID's of "offshore" and "programmers" and show the appropriate content.
What do you mean by "masking"? Is URL-rewriting, what you are searching for? If yes, you need to append the alias (e.g. "programmers") to the URL, instead of the GET-params. Those will be translated to GET-params via URL-rewriting and then matched to an ID via PHP.
I have a build a web portal based on the Cricket concept,
I have build a Custom based CMS where I can upload the News for the site
Once I upload the news, the URL Will be like this
http://cricandcric.com/news/news.php?id=841&An-emotional-moment:-Dhoni.html
But I am trying to have the above Url as follows (some thing like this)
http://cricandcric.com/news/An-emotional-moment:-Dhoni.html
Or similar to Stackoverflow.com,
Can any one please help me how can i build that?
Do I need to rewrite the URL ?
Yes, this is typically done with URL rewriting. This is a great intro to it.
Note that you'll have to make sure that the titles are unique, if you're removing the ID from the URL. (And you might as well get rid of the ".html" too)
Yes, as far as I can see you need to rewrite the URL. The URL "http://cricandcric.com/news/An-emotional-moment:-Dhoni.html" might be rewritten to "http://circandcric.com/news/index.php?title=An-emotional-moment:-Dhoni". Then, index.php has to figure out the correct news item from this title. This might be a source of problems (transformation of the title into URL-compatible string and back again), and, as Chad pointed out, the title has to be unique. If you get into trouble, check out how Stackoverflow handles this (ID as part of the URL, then title).
yeah Dude, .htaccess file will resolve all your Riddles.....Chk This--- How to use .htaccess file for rewriting URL?