Creating Clean URLS using PHP

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ย. 2024

ความคิดเห็น • 55

  • @erdesigns
    @erdesigns 6 ปีที่แล้ว +1

    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!

  • @rusofob12345
    @rusofob12345 9 ปีที่แล้ว

    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.

  • @ivanorezac
    @ivanorezac 8 ปีที่แล้ว +5

    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

    • @ZheerHalkawt
      @ZheerHalkawt 8 ปีที่แล้ว

      +ivanorezac i saw your comment and that made me to not watch the video xD

    • @ivanorezac
      @ivanorezac 8 ปีที่แล้ว

      +Emprator Z Actually the video is quite good, I'd recommend it.

    • @TheOnlyJura
      @TheOnlyJura 6 ปีที่แล้ว

      Yeah actually it's even pretty stupid since (FALSE || 'home') evaluates to TRUE...

    • @BaylorBreaksItDown
      @BaylorBreaksItDown  6 ปีที่แล้ว

      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.

  • @ampiyong
    @ampiyong 13 ปีที่แล้ว

    nice tuts...great explanations....

  • @AnovSiradj
    @AnovSiradj 11 ปีที่แล้ว

    awesome tutorial...,

  • @kervmeister69
    @kervmeister69 11 ปีที่แล้ว

    you're a real lifesaver...

  • @DevTalk
    @DevTalk 11 ปีที่แล้ว

    Smooth, Sweet, Clean

  • @cb5151
    @cb5151 10 ปีที่แล้ว

    major help thanks alot

  • @salimsikar
    @salimsikar 11 ปีที่แล้ว

    very nice ...

  • @ibrahimhasanov80
    @ibrahimhasanov80 8 ปีที่แล้ว +1

    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

  • @royallan864
    @royallan864 10 ปีที่แล้ว +2

    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.

  • @AnovSiradj
    @AnovSiradj 10 ปีที่แล้ว

    better than my way. nice

  • @BaylorBreaksItDown
    @BaylorBreaksItDown  14 ปีที่แล้ว

    I used ApacheFriends' XAMPP for Macintosh.

  • @royallan864
    @royallan864 10 ปีที่แล้ว +1

    And how do you make it work for search bars that use GET?

  • @AhmadAzizov
    @AhmadAzizov 11 ปีที่แล้ว

    Thanks!

  • @i_am_aravindan
    @i_am_aravindan 4 ปีที่แล้ว

    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?

  • @MrLahirukaka
    @MrLahirukaka 8 ปีที่แล้ว

    Thank you..

  • @soyebravat8903
    @soyebravat8903 8 ปีที่แล้ว

    is there anyway i can use htaccess to replace specific text in the url which i dont want to be viewed?

  • @_slier
    @_slier 13 ปีที่แล้ว

    @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

  • @fullbinky
    @fullbinky 14 ปีที่แล้ว

    thanks!

  • @byFeuz
    @byFeuz 9 ปีที่แล้ว

    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.

  • @sirounachouayakh6673
    @sirounachouayakh6673 11 ปีที่แล้ว

    I need your help , i want to index the url given in a result by google in my project

  • @b1rebel
    @b1rebel 11 ปีที่แล้ว

    oh nice :D

  • @wimdemortier3281
    @wimdemortier3281 7 ปีที่แล้ว

    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?

  • @leessiloue7500
    @leessiloue7500 6 ปีที่แล้ว

    Thanks for this tutorial but it would be nicer if you zoom in to the text portion instead of showing the entire desktop.

    • @BaylorBreaksItDown
      @BaylorBreaksItDown  6 ปีที่แล้ว

      Lees thank you. That’s something I learned later on I guess!

  • @frm683600
    @frm683600 11 ปีที่แล้ว

    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.

  • @winfr34k
    @winfr34k 14 ปีที่แล้ว

    what did you install for your localhost?

  • @DanielJausovec
    @DanielJausovec 11 ปีที่แล้ว

    Hello.
    This script work perfect but does not work in ajax request.
    Do you have any idea why not?

  • @samhoeun7172
    @samhoeun7172 10 ปีที่แล้ว +1

    why Adding a forward slash to the end of my URLs is breaking them?

    • @YoungBud03
      @YoungBud03 10 ปีที่แล้ว

      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

    • @samhoeun7172
      @samhoeun7172 10 ปีที่แล้ว

      thanks,,, now i want to create a dynamic web with clean url, but i cannot

    • @PawelKolo
      @PawelKolo 10 ปีที่แล้ว +1

      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.

  • @binodguitarspots2078
    @binodguitarspots2078 7 ปีที่แล้ว +1

    can we hide id but fetch data uniquely....?.

    • @BaylorBreaksItDown
      @BaylorBreaksItDown  7 ปีที่แล้ว

      +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.

  • @_slier
    @_slier 13 ปีที่แล้ว

    is there a way to make clean url just using php?

  • @adisurd
    @adisurd 10 ปีที่แล้ว +3

    Nice info, but a 5 minute tutorial was bloated into a 22 minute, ill prepared ramble.

  • @thegioigiaitri1384
    @thegioigiaitri1384 10 ปีที่แล้ว

    when i remove ''index.php" in url i've error 404 .

  • @boutalebbentsair9213
    @boutalebbentsair9213 8 ปีที่แล้ว

    you can replace $this->site_patch with dir ( $_SERVER ["SCRIPT_NAME"] ) ;

  • @stagge99
    @stagge99 12 ปีที่แล้ว

    Glimrande -> sparkling

  • @DevTalk
    @DevTalk 11 ปีที่แล้ว

    Can u upload the .htaccess file pls

  • @teraro2007
    @teraro2007 12 ปีที่แล้ว

    bro could yo please attach da pdf file ? Thnx

  • @Daniel-qo9uv
    @Daniel-qo9uv 7 ปีที่แล้ว

    source pleas i have an error on my source

  • @jowosolo
    @jowosolo 11 ปีที่แล้ว

    where i can download that script

  • @DavidCunningham123
    @DavidCunningham123 4 ปีที่แล้ว

    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

  • @marklesterdimpailis379
    @marklesterdimpailis379 11 ปีที่แล้ว

    thanks..
    can you upload the php code.. >_

  • @MaysMckenzie
    @MaysMckenzie 9 ปีที่แล้ว

    the source code please

  • @djatom7362
    @djatom7362 8 ปีที่แล้ว

    Please source code:)

  • @FlevasGR
    @FlevasGR 12 ปีที่แล้ว

    lol 2 dislikes......i think thos guys dont know what PHP means....

  • @mail2jimmy747
    @mail2jimmy747 14 ปีที่แล้ว

    confusing video