|
-
Oct 23rd, 2011, 09:37 AM
#1
[RESOLVED] Some doubts regarding URL rewrite
Hi 
I have been going through certain tutorial for some hours now, to know more about URL rewriting.
But I have a doubt:
If my site is kind of displaying articles, a sample link could be:
Code:
http://www.mysite.com/my-article-name-123
Where, 123 is the article id and the rest of the string is the article title. If a user types this address on his/her browser, we could easily match the last article id using regular expression(in Rewrite rules).
So the rewrited URL might look something like this:
Code:
http://www.mysite.com/showarticle.php?id=123
But how would we give this link. I mean, this link should be coming from somewhere. That is how this link will be created ?
If I'm not using the URL rewriting, I would use the address:
Code:
http://www.mysite.com/showarticle.php?id=123
for hyperlinks displayed in my site.
Eg:
Code:
<html>
<body>
<a href="http://www.mysite.com/showarticle.php?id=123">My First Article </a>
</body>
</html>
But in the case of URLs with article_names, how will I do it ? 
Thanks in advance
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Oct 23rd, 2011, 11:24 AM
#2
Re: Some doubts regarding URL rewrite
Write all URLs on your pages in their "pretty" format; if you don't publicize the query string-based URLs, no one has to know about them.
-
Oct 23rd, 2011, 12:03 PM
#3
Re: Some doubts regarding URL rewrite
Thanks 
What all things should I have to make it pretty ? One is, to replace the space character with a "-" character. What else should I have to do to that article title, inorder to make it neat.
If you were in place of me, what all things would you do. (let me know the steps)
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Oct 23rd, 2011, 12:21 PM
#4
Re: Some doubts regarding URL rewrite
Last edited by akhileshbc; Oct 23rd, 2011 at 12:25 PM.
Reason: found another solution
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Oct 23rd, 2011, 08:41 PM
#5
Re: Some doubts regarding URL rewrite
Make them short.
They should be created by humans, not simply encoded by a script.
Too many blogging platforms create long URIs out of titles. Instead, pick a key word and use that.
For example:
http://example.org/NiceURIs
Not
http://example.org/How_to_use_mod_rewrite_to_get_rid_of_query_strings
There should be one 'canonical' URI (the preferred version) as well as multiple others that can be used to access the same resource. If the user accesses the page through a 'non-canonical' URI, use a 301 redirect to send them to the proper one.
Also, I like using title case or sentence case, but make the URI parser case-insensitive, so that the user doesn't have to remember which letters to capitalise. If they use the wrong case, redirect to the correctly-cased URI.
Look at Wikipedia (the software they use, not a Wiki article) for an example of this done well.
Last edited by penagate; Oct 23rd, 2011 at 08:49 PM.
-
Oct 23rd, 2011, 11:30 PM
#6
Re: Some doubts regarding URL rewrite
Thanks 
So, the URI should be created once, should be short and has to be stored in the database. Isn't it ? Each time, when I display links of that articles, instead of creating the URI on the fly again, it should display the one that we have created.
Got it now.
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|