URL Rewriting in php - Full Tutorial

Поделиться
HTML-код
  • Опубликовано: 11 окт 2024
  • How to create Clean URL or SEO Friendly URL by .htaccess file. Create URL like facebook, twitter, google+.
    ►Link - bit.ly/21qytGh
    Create - home.php To home
    Create - user.php?id=1 To user/1
    Codes ----------------------------
    RewriteEngine On
    RewriteRule ^home?$ home.php
    RewriteRule ^user/([0-9]+) user.php?id=$1
    --------------------------------------
    ►Facebook - / thenishh
    ►RUclips - / thenishkhandk
    ►Google+ - plus.google.com...
    ►►Ask Me - danis.m2.m2
    ❝This video is only for educational or interest purpose only.
    Air Hockey Saloon by Chris Zabriskie is licensed under a Creative Commons Attribution license (creativecommon...)
    Source: chriszabriskie....
    Artist: chriszabriskie....

Комментарии • 124

  • @needyamin
    @needyamin 4 года назад +1

    I'm looking for no 3 tutorials more than 4 hours. at last I've got. Thanks

  • @galereyes07
    @galereyes07 8 лет назад +26

    Simple yet detailed! Thank you. Thumbs up for this tutorial. Keep it up :)

    • @thenishkhandk
      @thenishkhandk  8 лет назад +1

      Thanks

    • @fazaltaqui6424
      @fazaltaqui6424 6 лет назад

      Seyerelagsti hey i wanna be in friendly terms with you do u???😆😆

  • @trancevision83
    @trancevision83 8 лет назад +12

    Finally a proper video for .htaccess. Well done!

  • @anthony.guimack
    @anthony.guimack 7 лет назад +6

    Excellent tutorial, thank you very much.
    Happy New Year.

  • @cybertech4607
    @cybertech4607 4 года назад

    Nice Explanation

  • @harshachacko4989
    @harshachacko4989 4 года назад +1

    It's not working for me. Can u plz help me? There is no difference in my url even after applying this code.😞

  • @mosesoparah9523
    @mosesoparah9523 4 года назад

    I appreciated u with all my heart for this ... I watched other tutorials and lemme say what disturbed me before watching urs..For example
    RewriteRule ^shepherd shepherd/index.php
    RewriteRule ^sheep sheeper/sheep/index.php
    The first rewrite will affect the second one because d second has same shepherd/
    But after watching urs, I learnt
    RewriteRule ^shepherd?$ shepherd/index.php
    Thanks alot

  • @robertociulla1107
    @robertociulla1107 6 лет назад

    Number 1!!!!!!!!!! u have help me so much!!!!

  • @reubenjesu3543
    @reubenjesu3543 4 года назад

    Short and sweet, Well Explained

  • @cromlechs
    @cromlechs 8 лет назад

    Wow.... thanks for sharing ... I solved my problem with my script php ...and .htacces .... very useful.

  • @ristantosky
    @ristantosky 7 лет назад

    simple and clear tutorial ... thank you so much . keep sharing

    • @ristantosky
      @ristantosky 7 лет назад

      and question.. how to make the rewrite rule from link button . example :
      I have action button that contain : ..../report/myreport.php (it's jump upper one folder)
      I want to hide real address become : myreport (also need to jump upper one folder as need)
      thanks for answer

  • @jawadsaqib9916
    @jawadsaqib9916 5 лет назад

    Thank you sooooooooooooooooooooooooo Much finally find a proper video I was searching about this but it last find it here Thanks Again

  • @riobalvidades4821
    @riobalvidades4821 8 лет назад +1

    OHHHH MYYYYY GOD .. It's pretty simple code's but it's working awome .. men

  • @FlaviaSierro
    @FlaviaSierro 4 года назад +2

    OMG, I love you soo much, lol
    You just did it so esier. thank you for sharing your knowlegde.

  • @nartosligiyery7789
    @nartosligiyery7789 6 лет назад

    the best video on this topic that I've seen.

  • @aliamiri4524
    @aliamiri4524 6 лет назад +1

    was better than stackoverflow and other websites :) thanks ----- what's the music name ?

  • @PremKumar-sq7ve
    @PremKumar-sq7ve 7 лет назад

    Great. Simple But Clear Tutorial. Thank You Very Much.

  • @ArisFilms
    @ArisFilms 8 лет назад +4

    Thank you for this very simple and helpful video.

  • @gogoulor
    @gogoulor 7 лет назад

    friendly explanation without a word. thanks.

  • @gohilbhargav5250
    @gohilbhargav5250 5 лет назад

    Thank you. very good work.

  • @gauravk7343
    @gauravk7343 4 года назад

    Superb

  • @burhanauladi1233
    @burhanauladi1233 7 лет назад

    nice simple tutorial.. so easy to understand. thank you

  • @alidakhil3554
    @alidakhil3554 Год назад

    Very nice

  • @vishnu2737
    @vishnu2737 7 лет назад +1

    It's working fine. But I have one doubt how to restrict.php. For example test and test.php both are working on this tutorial, I need only test.

  • @shariarparves8789
    @shariarparves8789 5 лет назад

    nice and best

  • @stianskjelbred
    @stianskjelbred 7 лет назад

    Great and simple tut even my mom would understand. Subbed!

  • @ozkiremitci
    @ozkiremitci 8 лет назад +1

    Beautiful course. Thank you.

  • @noodley4200
    @noodley4200 7 лет назад +1

    Thanks for posting, I was looknig for exactly this.

  • @McGavel1
    @McGavel1 8 лет назад +1

    Thanks, this is exactly what I needed.

  • @sozver1353
    @sozver1353 7 лет назад

    You take a magnificent details

  • @kennyjoseph3266
    @kennyjoseph3266 7 лет назад

    You're a life saver! Thanks for posting this!

  • @squidward7091
    @squidward7091 6 лет назад

    Thank you very much, simple.

  • @gallbotondcalisthenicsGBC
    @gallbotondcalisthenicsGBC 4 года назад

    Very useful!

  • @maleknoui6038
    @maleknoui6038 8 лет назад +1

    thank's for this tutorial ;
    how protect (url data page/2/5) example replace --->delete_record?id=2¶m=5
    with delete.html

  • @AnkitKumar-fr7pv
    @AnkitKumar-fr7pv 5 лет назад

    It helped a lot... That You @ThenisH

  • @AbuSalehAbdullahAlMamun
    @AbuSalehAbdullahAlMamun 5 лет назад

    thumbs up, that's wonderful.

  • @ajithkumary55
    @ajithkumary55 6 лет назад

    Thank you so much.....

  • @leylajudy
    @leylajudy 7 лет назад

    Thank you so much ! very helpful

  • @abdelilahaassou6333
    @abdelilahaassou6333 7 лет назад +1

    Thank you for this explanation it's useful :)

  • @petern.3153
    @petern.3153 5 лет назад

    Thank you.
    You can expand the other code and how to use. simple [N,L], [R]

  • @nu_james
    @nu_james 4 года назад

    Thanks a lot bro, exactly what I needed !

  • @Labornol
    @Labornol 6 лет назад

    thankyou so much

  • @winex01
    @winex01 8 лет назад +1

    your fucking awesome -auto subscribed. thank you so much.

  • @الربحمنالانرنت-ز9ض

    great tutorial, thanks

  • @marcelniyitegeka2831
    @marcelniyitegeka2831 6 лет назад

    thank you so much, you did well

  • @alaanabawy3847
    @alaanabawy3847 6 лет назад

    Very Thanks

  • @thelineadventurer
    @thelineadventurer 4 года назад

    THANK YOU!

  • @MS-gt9ou
    @MS-gt9ou 7 лет назад +1

    thank you 😘😘

  • @deddygraphite
    @deddygraphite 7 лет назад

    Nice!!!!

  • @rex-yr1uz
    @rex-yr1uz 6 лет назад

    Thank you ❤️

  • @rezajohari9273
    @rezajohari9273 5 лет назад

    hi . thanks . but previous address is still available!! . the question is how can disable or hide previous address? thanks inadvance

  • @NGOTVQHTTV
    @NGOTVQHTTV 7 лет назад

    Thank you

  • @PedroOliveira10
    @PedroOliveira10 7 лет назад

    Thanks!

  • @mustaanabbasi
    @mustaanabbasi 8 лет назад +1

    How to deal with spaces in parameters? eXample test.php?id="test example".
    when I get value in user.php it only shows the first word. In this case which is 'test'.

    • @thenishkhandk
      @thenishkhandk  8 лет назад

      simply you can can convert whitespace to (- or +)sign and again replace (- or +)sign to whitespace on user.php
      EXAMPLE --->>
      for test.php------------------
      $id_value = 'test example';
      $converted = str_replace(" ","-",$id_value);
      for user.php------------------
      $id_value = $_GET['id'];
      $converted = str_replace("-"," ",$id_value);

    • @mustaanabbasi
      @mustaanabbasi 8 лет назад +1

      I tried it before, but it also gave the same results showing first word of string, than I tried this one and it resolved my problem: ^(.*)$

    • @thenishkhandk
      @thenishkhandk  8 лет назад

      good

    • @mustaanabbasi
      @mustaanabbasi 8 лет назад

      the reward goes to you, for such helpful tutorial. Thanks.

  • @moonbuster4667
    @moonbuster4667 5 лет назад

    tysm

  • @MartinMeli
    @MartinMeli 6 лет назад

    bravo!

  • @Programs4RScash
    @Programs4RScash 8 лет назад +1

    Great!

  • @Volun
    @Volun 7 лет назад

    I want to change player?id=729 to player/729 with ^player/([0-9]+) player?id=$1 but it doesn't show the expected content.
    I can call the page player/729, html structure is shown but it doesn't show my php echo content any more as if GET parameter isn't comitted

  • @VRIJRAJSINGH
    @VRIJRAJSINGH 8 лет назад

    Link between page with css & js has been remove , how to sol ?
    (when did /id=something )

  • @mitchelline
    @mitchelline 6 лет назад

    Genius

  • @relyontestmail3171
    @relyontestmail3171 5 лет назад

    how should i do this for a application consists of 500 php files and directories with sub directories all , this wont work for me

  • @deepakagarwal940
    @deepakagarwal940 5 лет назад

    thanks sir finaly i have remove .php but right now i dont change file name please help

  • @marconarco540
    @marconarco540 7 лет назад

    i see, so where i failed was that when i "change" the url my includes and everything goes one folder up. So instead of root js/scripts.js it goes into fakefolder/js/scripts.js. Is there a way to change this or i need to go on every single page and do it manually?

  • @nicogestiada7015
    @nicogestiada7015 6 лет назад

    When I refresh the page it goes back to original URL. What to do please help :(

  • @argelpamintuango1956
    @argelpamintuango1956 8 лет назад

    this aint working on my localhost..is there something I have to do in order to obtain that?

  • @neerajmishra961
    @neerajmishra961 6 лет назад

    Hi ThenisH,
    Thank for adding this Video for us.
    I have a question if you can resolve my problem .
    I have a url on subdomain like ab.abc.com and i load every time like this ab.abc.com/category
    now i need its details page so i created about.php and i write rules in htaccess file.
    RewriteEngine On
    RewriteRule ^profile/(.*)/(.*)/?$ about.php?category=$1&slug=$2
    when i run this this will work but my index that is based on this "ab.abc.com/category" display Not Found.
    Please note one thing i am handling index.php url with 3 parameters but not necessory all time these parameters are apply on url so i am using session to handle this.
    Kindly suggest me how can htaccess understand
    RewriteRule ^profile/(.*)/(.*)/?$ about.php?category=$1&slug=$2 only for about php
    if use without profile then it will understand that system load index.php
    Thanks

  • @bhadreshpipaliya3108
    @bhadreshpipaliya3108 8 лет назад

    exam.php?id=3 or exam.php?typr=hard or practice_exam?eid=7 or exam_conf?id=7 or result.php?type=test ....
    How Can Hide it Every Where?

  • @entertainment-ge2uv
    @entertainment-ge2uv 8 лет назад +1

    how load image or extenal css file..please help

    • @thenishkhandk
      @thenishkhandk  8 лет назад

      +entertainment ™
      Please explain me on - fb.com/thenishh

  • @parulrawat8194
    @parulrawat8194 6 лет назад

    hi please help when i try to convert localhost/astrology/details.php?id=2 into loclahost/astrology/details/2 when i apply .htacess to implement this... it works but breaks my CSS.. please help

    • @parulrawat8194
      @parulrawat8194 6 лет назад

      i am using in my .htaccess file this code RewriteRule ^details/([0-9]+)$ details.php?id=$1 [L] and in href path

  • @phptutorial258
    @phptutorial258 5 лет назад

    my css and images are not working

  • @newvemo
    @newvemo 6 лет назад

    when I click on the first link the contents get loaded, but when I click another link in the same page which shares the same RewriteRule, the link of the second gets added to the first link and no changes I get, Help me solve this problem please
    First click
    localhost/mazoezi/article/9/Event
    second click on another link
    localhost/mazoezi/article/9/article/11/Event
    my .htaccess file
    RewriteEngine On
    RewriteRule ^article/([0-9]+)/([0-9a-zA-Z]+) index.php?id=$1&type=$2

  • @panneraec
    @panneraec 7 лет назад

    RewriteRule ^user/([0-9]+) user.php?id=$1
    Above Code now working , Geting obect not found .
    Please let me know the solution

  • @istiaqhasan9220
    @istiaqhasan9220 8 лет назад +4

    Thank You.
    How to make
    domain.com/user.php?username=abc
    to
    domain.com/abc
    e.g: facebook.com/thenishh
    Again Thanks for Sharing this.

    • @thenishkhandk
      @thenishkhandk  8 лет назад +1

      +Istiaq Hasan
      --------------------------------------------------
      RewriteEngine On
      ReWriteRule ^([a-z]+)$ user.php?username=$1
      ----------------------------------------------------
      Note: Please don't user any number and symbol in username Only Alphabets
      try above codes. if have any problem so please ask me...

    • @istiaqhasan9220
      @istiaqhasan9220 8 лет назад

      +thenish khan thank you very much. But if want to use symbol like dot (.) in the username what is the rewrite rule?
      Like my FB id is facebook.com/istiaq.pro

    • @thenishkhandk
      @thenishkhandk  8 лет назад +1

      +Istiaq Hasan
      ruclips.net/video/wvmROF0xrVU/видео.html

  • @ozkiremitci
    @ozkiremitci 8 лет назад +2

    How to www.tld.com/test.php enter redirect www.tld.com/test ?

    • @thenishkhandk
      @thenishkhandk  8 лет назад

      +A.Malik ÖZKİREMİTÇİ
      ----------------------------------------------------------------
      RewriteEngine On
      RewriteRule ^test?$ test.php
      ----------------------------------------------------------------
      copy & paste above codes in .htaccess file. Please reply me if it works Or not.

    • @ozkiremitci
      @ozkiremitci 8 лет назад +1

      +thenish khan Don't work. /test enter work it. But /test.php display www.website.com/test.php. Don't redirect /test page.

    • @thenishkhandk
      @thenishkhandk  8 лет назад

      +A.Malik ÖZKİREMİTÇİ
      --------------------------
      RewriteEngine On
      RewriteRule ^/test$ /test.php [L]
      ----------------------------
      are you saving .htaccess file in public_html folder ???
      please give me a screenshot where did you save .htaccess file...

    • @ozkiremitci
      @ozkiremitci 8 лет назад

      +thenish khan Yes. Test on Localhost and public_html.
      But my test site root example:
      www.site.com/test/example/
      ############################
      my .htaccess file;
      Options +FollowSymLinks
      # Prevent Directoy listing
      Options -Indexes
      RewriteEngine On
      RewriteBase /test/example/
      #RewriteRule ^test?$ test.php
      RewriteRule ^/test$ /test.php [L] #error: not found !

    • @thenishkhandk
      @thenishkhandk  8 лет назад

      +A.Malik ÖZKİREMİTÇİ
      bro this example file. i hope you can understand.
      Link - is.gd/urlex

  • @sujanlawot9533
    @sujanlawot9533 8 лет назад

    After i did this
    RewriteRule ^news/([0-9]+) news.php?did=$1
    and open in browser as .../news/5
    css js and plugins are not taking..

    • @thenishkhandk
      @thenishkhandk  8 лет назад

      you need put the correct and full address of css, js file
      Wrong --> "/css/style.css"
      Correct --> "website/css/style.css

    • @sujanlawot9533
      @sujanlawot9533 8 лет назад

      But when i click the link contact from news/5 then the browser opens as news/5/contact... how can i open contact link on clicking from news/5

    • @thenishkhandk
      @thenishkhandk  8 лет назад

      Again you need put the correct and full address of link

  • @pvenkatesh100
    @pvenkatesh100 8 лет назад

    hi i done with out .php but i unable to do querystring
    RewriteRule ^steroids/([0-9]+) steroids.php?page_id=$1
    anchor tag
    href="steroids/">

  • @navaspixelbirdindia6768
    @navaspixelbirdindia6768 8 лет назад

    its not working on local server

    • @navaspixelbirdindia6768
      @navaspixelbirdindia6768 8 лет назад

      wamp server
      Internal Server Error
      The server encountered an internal error or misconfiguration and was unable to complete your request.
      Please contact the server administrator at admin@example.com to inform them of the time this error occurred, and the actions you performed just before this error.
      More information about this error may be available in the server error log.
      Apache/2.4.9 (Win32) PHP/5.5.12 Server at localhost Port 80

    • @thenishkhandk
      @thenishkhandk  8 лет назад +1

      +Navas Pixelbird
      Fix Internal Server Error on wamp : ruclips.net/video/izaD49eYKp4/видео.html

    • @navaspixelbirdindia6768
      @navaspixelbirdindia6768 8 лет назад +1

      +thenish khan just try this url in your server
      localhost/htaccess/user/1/3/4/5/46/5/54/54kjh/43dgsdf

    • @navaspixelbirdindia6768
      @navaspixelbirdindia6768 8 лет назад

      +Navas Pixelbird
      got it use ?$ at the end

    • @thenishkhandk
      @thenishkhandk  8 лет назад

      +Navas Pixelbird
      i will try this URL after some days because now i am out of town

  • @hitecnetworks
    @hitecnetworks 5 лет назад

    how can i rewrite this url
    sms.hitecdeveloper.com/admin/print_id.php?code=43742
    to this url
    sms.hitecdeveloper.com/admin/print_id/43742

  • @ElRubenMC1
    @ElRubenMC1 8 лет назад

    Don't works for me :/

    • @thenishkhandk
      @thenishkhandk  8 лет назад

      +Ruben Villegas
      what isn't working ?

    • @ElRubenMC1
      @ElRubenMC1 8 лет назад +1

      +thenish khan This is my .htacces
      # BEGIN
      RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME}.php -f
      RewriteRule ^(.+)$ /$1.php [L,QSA]
      RewriteRule ^u/([.*]+) u.php?id=$1
      ErrorDocument 404 /404
      ErrorDocument 500 /500
      # END

  • @Unsichtbarxxx
    @Unsichtbarxxx 8 лет назад +1

    very simpel to understand good example ;) thank

  • @mastercoria.com_
    @mastercoria.com_ 6 лет назад

    What happens if I want to keep both "User ID" and "My ID". I put the two ones and occurs an error. I mean: can access "user/[anything]" or "user/[anything]/[anything]"