Thank you for the tutorial, i was working on a very very simple router.. just for 3 pages, and dont want to use a complete framework for such simple task. It only needs to route some names or ids.. this works like a charm!! Ive been looking for this a while, never got it to work, untill i found ur tutorial! thanks again!
I love it how you said if( $url == ( blank || 'home' ) ) And I was like THAT IS AWESOME, how come I've never seen that, I've been looking for that all my life, and it turns out it isn't a valid expression haha
Whole Url cleans that I have seen before and also now have bug.This bug is about if User going to write ...product/category/12/a/a/a/a/s/d/asd//asf/as/df/as/df//asd/fa/sd/fas/df/as/df/ It will run Like ...product/category/12
So then how do you load get variables like site.com/page/id/page_num/edit while php site.com/page or site.com/?p=pagename&id=4147&p_id=2&mode=edit so from get array $_GET["p"] I would have to instead use a numbering system to hold the structure of the vars? like site.com/page/id/page_num/edit basename["1"] to make it dynamic or name manuly to get baseneame['p'] by keywords.
Dear Sir, How to do with multiple segment. For eg: i have page called about and i have sub page of about named as overview Which is like "about/overview" Similarly when i use "overview" is not working only "about" is working. Can you give me a suggestion?
@coolcam262 are you sure? cause i been dissecting couple of cms and they got clean url without using any .htaccess file...i think they using some sort of router class
So then how do you load get variables like site.com/page/id/page_num/edit while php site.com/page or site.com/?p=pagename&id=4147&p_id=2&mode=edit so from get array $_GET["p"] I would have to instead use a numbering system to hold the structure of the vars? like site.com/page/id/page_num/edit basename["1"] to make it dynamic or name manuly to get baseneame['p'] by keywords.
Works great! A very nice way of clean URL's. I have one question. I want a url www.site.com/user/name to point the user to following path: www.site.com/user/index.php?user=name. I always get a blank page. When I use www.site.com/user/ this points to the folder user without problem. I can't use a second segment. Any suggestions?
Nice tutorial, but when tried this in my loclhost xampp it's not actually working. for example after setting up the simpleUrl class and index.php when visit this URL in my localhost localhost/clean_urls/products/category/12/ it's displaying me as "Object Not Found" anybody has idea? It look like to my it's trying to find the product folder and category folder.
Forward Slashes is only for directories, you can add this RewriteRule ^(profile/[0-9]+)$ /$1/ [R=301] RewriteRule ^(blog/[0-9]+)$ /$1/ [R=301] To add the ending slash to the URL
Use something like this: if (substr($this->url, -1, 1) == "/") { $this->url = substr($this->url, 0, strlen($this->url) - 1); } Where "$this->url" is the full request. Thats remove last slash if any exists.
+Binod Pal you could create a new column on your record called “slug” which would have a unique index in your database. Generally a slug is all lower case with non alphanumeric characters removed and spaces replaced with dashes. If you want the id to be random you could generate a string with “bin2hex(random_bytes(8))” when creating a new record.
Thank you for the tutorial, i was working on a very very simple router.. just for 3 pages, and dont want to use a complete framework for such simple task. It only needs to route some names or ids.. this works like a charm!! Ive been looking for this a while, never got it to work, untill i found ur tutorial! thanks again!
Thank you very much, searched a lot on Internet, but couldn't find how to upload content on dynamically created pages, but your video helped.
I love it how you said if( $url == ( blank || 'home' ) )
And I was like THAT IS AWESOME, how come I've never seen that, I've been looking for that all my life, and it turns out it isn't a valid expression haha
+ivanorezac i saw your comment and that made me to not watch the video xD
+Emprator Z Actually the video is quite good, I'd recommend it.
Yeah actually it's even pretty stupid since (FALSE || 'home') evaluates to TRUE...
It’s been a while since I watched the video but I believe that would be the correct case no? If home is the equivalent of an empty route.
nice tuts...great explanations....
awesome tutorial...,
you're a real lifesaver...
Smooth, Sweet, Clean
major help thanks alot
very nice ...
Whole Url cleans that I have seen before and also now have bug.This bug is about if User going to write ...product/category/12/a/a/a/a/s/d/asd//asf/as/df/as/df//asd/fa/sd/fas/df/as/df/ It will run Like ...product/category/12
So then how do you load get variables like site.com/page/id/page_num/edit
while php site.com/page or site.com/?p=pagename&id=4147&p_id=2&mode=edit
so from get array $_GET["p"] I would have to instead use a numbering system to hold the structure of the vars? like site.com/page/id/page_num/edit basename["1"] to make it dynamic or name manuly to get baseneame['p'] by keywords.
better than my way. nice
I used ApacheFriends' XAMPP for Macintosh.
And how do you make it work for search bars that use GET?
Thanks!
Dear Sir,
How to do with multiple segment. For eg:
i have page called about and i have sub page of about named as overview
Which is like "about/overview"
Similarly when i use "overview" is not working only "about" is working.
Can you give me a suggestion?
Thank you..
is there anyway i can use htaccess to replace specific text in the url which i dont want to be viewed?
@coolcam262
are you sure? cause i been dissecting couple of cms and they got clean url without using any .htaccess file...i think they using some sort of router class
thanks!
So then how do you load get variables like site.com/page/id/page_num/edit
while php site.com/page or site.com/?p=pagename&id=4147&p_id=2&mode=edit
so from get array $_GET["p"] I would have to instead use a numbering system to hold the structure of the vars? like site.com/page/id/page_num/edit basename["1"] to make it dynamic or name manuly to get baseneame['p'] by keywords.
I need your help , i want to index the url given in a result by google in my project
oh nice :D
Works great! A very nice way of clean URL's. I have one question. I want a url www.site.com/user/name to point the user to following path: www.site.com/user/index.php?user=name. I always get a blank page. When I use www.site.com/user/ this points to the folder user without problem. I can't use a second segment. Any suggestions?
Thanks for this tutorial but it would be nicer if you zoom in to the text portion instead of showing the entire desktop.
Lees thank you. That’s something I learned later on I guess!
Nice tutorial, but when tried this in my loclhost xampp it's not actually working. for example after setting up the simpleUrl class and index.php when visit this URL in my localhost localhost/clean_urls/products/category/12/ it's displaying me as "Object Not Found" anybody has idea? It look like to my it's trying to find the product folder and category folder.
what did you install for your localhost?
Hello.
This script work perfect but does not work in ajax request.
Do you have any idea why not?
why Adding a forward slash to the end of my URLs is breaking them?
Forward Slashes is only for directories, you can add this
RewriteRule ^(profile/[0-9]+)$ /$1/ [R=301]
RewriteRule ^(blog/[0-9]+)$ /$1/ [R=301]
To add the ending slash to the URL
thanks,,, now i want to create a dynamic web with clean url, but i cannot
Use something like this:
if (substr($this->url, -1, 1) == "/")
{
$this->url = substr($this->url, 0, strlen($this->url) - 1);
}
Where "$this->url" is the full request. Thats remove last slash if any exists.
can we hide id but fetch data uniquely....?.
+Binod Pal you could create a new column on your record called “slug” which would have a unique index in your database. Generally a slug is all lower case with non alphanumeric characters removed and spaces replaced with dashes. If you want the id to be random you could generate a string with “bin2hex(random_bytes(8))” when creating a new record.
is there a way to make clean url just using php?
Nice info, but a 5 minute tutorial was bloated into a 22 minute, ill prepared ramble.
when i remove ''index.php" in url i've error 404 .
you can replace $this->site_patch with dir ( $_SERVER ["SCRIPT_NAME"] ) ;
Glimrande -> sparkling
Can u upload the .htaccess file pls
bro could yo please attach da pdf file ? Thnx
source pleas i have an error on my source
where i can download that script
For everyone who wanted the pdf cheet sheet, I found it online here... appletree.or.kr/quick_reference_cards/Apache/mod_rewrite-cheat-sheet-v2.pdf
thanks..
can you upload the php code.. >_
the source code please
Please source code:)
lol 2 dislikes......i think thos guys dont know what PHP means....
confusing video