If you lose the linkage to your images, css, js or any external files... read this below: That happens when we use relative paths to resources in our page. Change: images/1.jpg to /images/1.jpg Add / before the relative path to the external resources that seem to have disappeared. What that does is makes the path absolute instead of relative, meaning the file can access the resources like normal. It behaves that way because those rewrite directories do not actually exist on the server so the file has trouble finding the relatively linked to resource. Or use the full absolute URL path to the external resource the page is linking to.
you need put the correct and full address of css, js file Wrong --> "/css/style.css" Correct --> "website/css/style.css It will solve all the problems...
Adam, You might not remember me I used to be your top responder on your old forums, Just like to mention this is the only tutorial on the internet that could teach me this. It's easier than I thought but everyone else couldn't explain it very well.
I found you once years ago and then I lost you. Now I found you again. Thank God! You're the best ever Adam. This world needs someone who flat out tells you how to do something and you do it in a way that anyone can understand. I hope you never ever stop making videos man. You are a blessing.
This is the best Apache tutorial on Earth. 24 hours and 100+ sites prior, amounted to confusion and frustration. Great job Adam! You're bookmarked in my php favourites but I didn't realise you did Apache until I stumbled across this most excellent tutorial.
Incredible & detailed tutorial! Thank you for really taking the effort in explaining everything from start to finish as I've seen other tutorials that weren't as informative and that ended up resulting in errors! Kudos
Adam - I have been following you for roughly 5 years now. Your content is always amazing. After a few months of daily programming grinding at work, I haven't really had the need to do much code research. Just today, I was looking into delving into this subject and just did a google search. After going through 3 tutorials that all did not work, I found yours (should have went to DevPHP first) and got it to work right away. You are truly amazing. Thank you for all that you do for the community!
Hi from South Africa. Adam, I can't thank you enough for this video! I've been struggling with this for over 2 years and finally someone (you) explained so I can understand! Again thank you so much!
Hi Adam, Getting difficulty when I have multiple inner page of a main page (category-list.php). Such as: A. category-list/inner-category1 B. category-list/inner-category1/sub-inner-page If I use 2 steps rewrite URL process, first. I works correctly for sub-inner-page. But if I write for single step rewrite URL below 2 steps. The first one overwrites previous one. And stops displaying page. RewriteRule ^category-list/([a-zA-Z]+)/([0-9a-zA-Z_-]+) category-list.php?a=$1&b=$2 [NC,L] RewriteRule ^category-list/([0-9a-zA-Z]+) category-list.php?a=$1 [NC,L] Same goes vice versa.
Excellent clip. Much useful information. The only issue I'm having is that ^custom tells the server and user client (browser) to drop down to a directory that doesn't actually exist. This works, but the path names to my includes get all screwed up because the server expects the files to be in that directory and not one up. Also, the user client is looking for files, like images, in the same manner and can't find them. How can I get the semantic URL's to all pull from the top-level index file, like WordPress?
Really nice and simple tutorial but this code is working with id=1, but not working with id=10 or id=100. Means only single value is working. Even after applying the tag. Can you help me?
Adam can you create a tutorial on creating auction site and a multilingual website with php. I have learned a lots of things from you and your tutorials are very easy to understand. Thanks for what you are doing.
Saw your video today. It really helped me to understand the concept and implement it. I loved your explanation style i clearly understood anything. Do you have any tutorial related to namespace in php5.
Nice video! I'm so excited to wait next videos from you adam. can you give me suggestion to use PHP native or PHP framework?? and can you explain why u suggest to use that? and advantages and disadvantages? now I'm using PHP native but when i work in group they suggest me to learn framework and i see your tutorial always use PHP native. thanks a lot Adam i hope you could give me best answer to me.
Right on. Don't feel bad. I've been a working professional in the web dev industry for 17 years and server directives are still something I have to learn more about, and gain a better grasp on. I'm not hyper focused on that aspect, but some people are and they make me look like I'm finger-painting while they paint masterpieces.
What if we want the old ugly URLs to redirect to the new clean ones, because I think if we leave them like that, we will have an SEO problem which is duplicate content.
thanks for the tutorial. I´m trying to set up a rewrite and wanted to redirect the old url to the new one. If I use your user example with mine I get a blank page. is it possible to directly redirect the new one to the old one? Thanks!
Thanks for youreffort and clear explanation:-), I'm trying this on my local webserver using WAMP, and I'm getting the 500 internal error message. Can this be done on a local server or do I need to use a live one?
you only get error 500 if either the .htaccess file is corrupt or if you have incorrectly typed something. try commenting out each line in your .htaccess file by putting the hashtag in front of the line and refresh until you find the one causing the problem, then its just a matter of correcting it. In some cases some rules may conflict with eachother as well
Hi, Adam.first of all really thankful to, I am learning a lot with your tutorials. I wanna ask you a question. Well, I have recently built a webpage but this webpage is repeatedly attacked by malicious elements. so as i was watching this video i was thinking, my urls in the website lokk like example.com/page.php, being page.php the real page located on the server. Is it posible that if i rewrite my urls, i'll be more safe against those malicious elements ...Thank you very much.
i love the potential of this tutorial but right now i am at a point of falure with applying this to WI2 series. my .htaccess just doesnt seem to be doing anthing.
thanks for the great tut's ,, can u plz make a tuts where in we can ask htaccess to skip few pages (like about us / contact us etc pages ) and activate slug on on profile page / details page / user page etc (basically asking where dynamic content is required.. ) this was the first part .. second part is fetching dynamic content from article .. it show www.web.com/article/ 1/new article now how can we make it to render www.web.com/new article hiding in between dynamic values.. if possible... looking forward can it be possible to have both requirement in 1 .htaccess file thanks in advance
If you lose the linkage to your images, css, js or any external files... read this below:
That happens when we use relative paths to resources in our page.
Change:
images/1.jpg
to
/images/1.jpg
Add / before the relative path to the external resources that seem to have disappeared. What that does is makes the path absolute instead of relative, meaning the file can access the resources like normal. It behaves that way because those rewrite directories do not actually exist on the server so the file has trouble finding the relatively linked to resource. Or use the full absolute URL path to the external resource the page is linking to.
it doesnt work for me
it's not working for me
For your local version add
to the head section
and for your live versions change it to
reference at www.w3.org/TR/html4/struct/links.html#h-12.4
it is not working to me
you need put the correct and full address of css, js file
Wrong --> "/css/style.css"
Correct --> "website/css/style.css
It will solve all the problems...
Sounds crazy, but this is the first time I found a tutorial that actually made sense for rewriterule
Adam, You might not remember me I used to be your top responder on your old forums, Just like to mention this is the only tutorial on the internet that could teach me this. It's easier than I thought but everyone else couldn't explain it very well.
You've literally made a solution video for every single problem that I face while I'm coding. Thanks Adam
I found you once years ago and then I lost you. Now I found you again. Thank God! You're the best ever Adam. This world needs someone who flat out tells you how to do something and you do it in a way that anyone can understand. I hope you never ever stop making videos man. You are a blessing.
This is the best Apache tutorial on Earth. 24 hours and 100+ sites prior, amounted to confusion and frustration. Great job Adam! You're bookmarked in my php favourites but I didn't realise you did Apache until I stumbled across this most excellent tutorial.
Incredible & detailed tutorial! Thank you for really taking the effort in explaining everything from start to finish as I've seen other tutorials that weren't as informative and that ended up resulting in errors! Kudos
Adam - I have been following you for roughly 5 years now. Your content is always amazing. After a few months of daily programming grinding at work, I haven't really had the need to do much code research. Just today, I was looking into delving into this subject and just did a google search. After going through 3 tutorials that all did not work, I found yours (should have went to DevPHP first) and got it to work right away. You are truly amazing. Thank you for all that you do for the community!
Glad to hear that Randy! Thanks for the kind words.
I was researching this a couple of days ago... now I don't have to anymore.
Thank you for making this awesome video :)
This is the best explanation of this that I have ever found! Every little detail that I had questions about was answered. Thank you so much!
Nice one! Just a quick tip:
When saving with notepad, choose UTF-8 encoding and not the default ANSI encoding.. ;)
I just want to guess why it is better to save it as UTF-8 , because it has a greater character support? correct? Thanks.
Hi from South Africa. Adam, I can't thank you enough for this video! I've been struggling with this for over 2 years and finally someone (you) explained so I can understand! Again thank you so much!
Are you reading my mind? When I think I got to learn something you post a video about it. Thank you very much for that. =D
شكرا يا ادم شرح بسيط و ممتاز انت الرجل المناسب في المكان المناسب و مزاياك علينا كثيرة !!!!
i was trying things out for hours until i came up here, thanks! you explained everything really calm and easy thnx man!
The perfect tutorial. Short but complete and very clear. On point 👍
very well explained brother....
Still an amazing tutorial after so many years! Thanks mate
awesome.....after 4 hours of searching u made it super simple....
Adam, I am amazed by your explanation, the way you pass on the knowledge. Bravo!
You earned a new subscriber! :)
Really great video, you make me understand, at least at the most part, how htaccess works!
YOU'RE THE BEST ADAM.. YOU SAVED ME $300 OF CUSTOMIZATION MONEY.. GOD BLESS YOU
Hi Adam,
Getting difficulty when I have multiple inner page of a main page (category-list.php).
Such as:
A. category-list/inner-category1
B. category-list/inner-category1/sub-inner-page
If I use 2 steps rewrite URL process, first. I works correctly for sub-inner-page. But if I write for single step rewrite URL below 2 steps.
The first one overwrites previous one. And stops displaying page.
RewriteRule ^category-list/([a-zA-Z]+)/([0-9a-zA-Z_-]+) category-list.php?a=$1&b=$2 [NC,L]
RewriteRule ^category-list/([0-9a-zA-Z]+) category-list.php?a=$1 [NC,L]
Same goes vice versa.
Im have this problem. No solution for this?
Anyone has an answer for this? I have the same problem
I finally understood url rewriting thanks to you!
Awesome tutorial, I am looking for this for a long time. Thanks Adam.
Thank you for this. Very much appreciated
You're very welcome
Exactly what I was looking for! Thanks a lot!!!
ty
+1 follower
Clean as a clean URL.
Thank you!
Adam you are a legend mate. thanks for uploading this video. appreciated !!!
Beautifully explained video. Thank you.
Thanks. Adam. You made my life easier!
Ive finally found the solution to what Ive been looking for... Thanks alot
Very good ! Thanks Adam, you are a great teacher !
You're a lifesaver, finally, I got some lesson about it
Thanks man! You always make great tutorials but this... Saved my life! Don't you know how..
This is exactly what I was looking for! Thanks Adam :)
Love the way you teach! Thanks man for your time!
I find this video really helpful .. Thank you Adam! Js 24/7 Hurray !!
9 years later and still relevant
Thanks!!!! Adadm,
I was very struggling with this. .great tutorial ..
Great tutorial, was really struggling with this. Thanks!
+ChiefKamek Glad it helps, thanks for taking the time to comment.
Excellent tutorial, very clear and simple to follow yet powerful enough! :D
+Animal Breading Fu
nice tutorial..
a sincere blessing from hong kong..
god bless..
^___^
After some hours l found this tutorial That solves my problem.
Loved it brother! Loved it! 😍
it's working ..... thank you so much sir...... :) from kerala ..
the clearest explanation i've come across so far. but how do we change the actual domain name as opposed to sub dirs?
Thank you so much, literally nobody explains how htaccess works they just copy and paste the "solution" for them but that's not my solution
Great addition to the curriculum!
Thanks for sharing it. Excellent👍
Excellent clip. Much useful information. The only issue I'm having is that ^custom tells the server and user client (browser) to drop down to a directory that doesn't actually exist. This works, but the path names to my includes get all screwed up because the server expects the files to be in that directory and not one up. Also, the user client is looking for files, like images, in the same manner and can't find them. How can I get the semantic URL's to all pull from the top-level index file, like WordPress?
nice now am clear about URL re writing thank you a lot
Thank you very much! Very effective and easy!! for a beginner like me really helped me alot.
Really nice and simple tutorial but this code is working with id=1, but not working with id=10 or id=100. Means only single value is working. Even after applying the tag. Can you help me?
You're a savior, sir! Thank you! :)
the best tutorial !! thank u so much , Brother !!
Adam can you create a tutorial on creating auction site and a multilingual website with php. I have learned a lots of things from you and your tutorials are very easy to understand. Thanks for what you are doing.
Saw your video today. It really helped me to understand the concept and implement it. I loved your explanation style i clearly understood anything. Do you have any tutorial related to namespace in php5.
Love your content. This was very helpful. Thank you.
You know what man? I like your style.
This is just awesome. works beautifully thanks. Jut what I needed
Great tutorial. Made it so simple.
Thanks !!!
now i can make clean url to my project
Why did all the tutorials I read before this make it seem so difficult? You made it so easy. Thanks.
Thank you for this video! Really helpful.
Thank guy for a good tutorial. It's helpful. Wish you best of luck.
Great tutorial!
Thanks. That's all I needed to know :)
Kind regards.
Nice video! I'm so excited to wait next videos from you adam. can you give me suggestion to use PHP native or PHP framework?? and can you explain why u suggest to use that? and advantages and disadvantages?
now I'm using PHP native but when i work in group they suggest me to learn framework and i see your tutorial always use PHP native.
thanks a lot Adam i hope you could give me best answer to me.
Beautiful tutorial.
Harika bir anlatım! Çok teşekkür ederim :)
Thank you very much,best tutorial
htaccess is so confusing... but I'm determined to get the basics of it down lol
Right on. Don't feel bad. I've been a working professional in the web dev industry for 17 years and server directives are still something I have to learn more about, and gain a better grasp on. I'm not hyper focused on that aspect, but some people are and they make me look like I'm finger-painting while they paint masterpieces.
@@AdamKhoury I had ChatGPT help with htaccess and it struggled
very very useful ...thank you so much sir ... salute you
Adam you are the MAN!!
love you men ! thanks for video
I love you too!
Hey adam thanks for this video it really helped me
This was very helpful, thanks! :)
What if we want the old ugly URLs to redirect to the new clean ones, because I think if we leave them like that, we will have an SEO problem which is duplicate content.
thank you so much !!!! Adam sir !
nice guide, thanks! out of interest, is there anyway to make the .php URL inaccessible? (so people can only get there via the rewritten link)
Thanks for the vid. You seem like a nice guy.
thanks for the tutorial. I´m trying to set up a rewrite and wanted to redirect the old url to the new one. If I use your user example with mine I get a blank page. is it possible to directly redirect the new one to the old one? Thanks!
if anyone still encounters the problem with css/images/etc. not loading after rewriting, try:
it worked for me...place it between the tags
Thanks for youreffort and clear explanation:-), I'm trying this on my local webserver using WAMP, and I'm getting the 500 internal error message. Can this be done on a local server or do I need to use a live one?
you only get error 500 if either the .htaccess file is corrupt or if you have incorrectly typed something. try commenting out each line in your .htaccess file by putting the hashtag in front of the line and refresh until you find the one causing the problem, then its just a matter of correcting it. In some cases some rules may conflict with eachother as well
Thanks a lot. It was very useful :)
Great tutorial. Learned a lot. Added the needed code to a module on my site. Created "Uncaught SyntaxError: Unexpected token
Hi, Adam.first of all really thankful to, I am learning a lot with your tutorials. I wanna ask you a question. Well, I have recently built a webpage but this webpage is repeatedly attacked by malicious elements. so as i was watching this video i was thinking, my urls in the website lokk like example.com/page.php, being page.php the real page located on the server. Is it posible that if i rewrite my urls, i'll be more safe against those malicious elements ...Thank you very much.
the best tutorial , thank u so much .
i love the potential of this tutorial but right now i am at a point of falure with applying this to WI2 series. my .htaccess just doesnt seem to be doing anthing.
yes me too
Great video. Thanks a lot!
Thanks man you saved my day
Great explanation ty.
Great tutorial, thanks!
thanks a lot! you really help me so much.
Very helpful, thanks
Thank you . it was really clear . :)
Hey Adam! Is this code for Apache 2.2 or 2.4? I think they changed some syntax for .htaccess in 2.4 version.
thanks for the great tut's ,, can u plz make a tuts where in we can ask htaccess to skip few pages (like about us / contact us etc pages ) and activate slug on on profile page / details page / user page etc (basically asking where dynamic content is required.. ) this was the first part ..
second part is fetching dynamic content from article .. it show www.web.com/article/ 1/new article
now how can we make it to render www.web.com/new article hiding in between dynamic values.. if possible... looking forward can it be possible to have both requirement in 1 .htaccess file thanks in advance