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....
I'm looking for no 3 tutorials more than 4 hours. at last I've got. Thanks
Simple yet detailed! Thank you. Thumbs up for this tutorial. Keep it up :)
Thanks
Seyerelagsti hey i wanna be in friendly terms with you do u???😆😆
Finally a proper video for .htaccess. Well done!
Excellent tutorial, thank you very much.
Happy New Year.
Nice Explanation
It's not working for me. Can u plz help me? There is no difference in my url even after applying this code.😞
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
Number 1!!!!!!!!!! u have help me so much!!!!
Short and sweet, Well Explained
Wow.... thanks for sharing ... I solved my problem with my script php ...and .htacces .... very useful.
simple and clear tutorial ... thank you so much . keep sharing
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
Thank you sooooooooooooooooooooooooo Much finally find a proper video I was searching about this but it last find it here Thanks Again
OHHHH MYYYYY GOD .. It's pretty simple code's but it's working awome .. men
OMG, I love you soo much, lol
You just did it so esier. thank you for sharing your knowlegde.
the best video on this topic that I've seen.
was better than stackoverflow and other websites :) thanks ----- what's the music name ?
Great. Simple But Clear Tutorial. Thank You Very Much.
Thank you for this very simple and helpful video.
friendly explanation without a word. thanks.
Thank you. very good work.
Superb
nice simple tutorial.. so easy to understand. thank you
Very nice
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.
nice and best
Great and simple tut even my mom would understand. Subbed!
Beautiful course. Thank you.
Thanks for posting, I was looknig for exactly this.
Thanks, this is exactly what I needed.
You take a magnificent details
You're a life saver! Thanks for posting this!
Thank you very much, simple.
Very useful!
thank's for this tutorial ;
how protect (url data page/2/5) example replace --->delete_record?id=2¶m=5
with delete.html
It helped a lot... That You @ThenisH
thumbs up, that's wonderful.
Thank you so much.....
Thank you so much ! very helpful
Thank you for this explanation it's useful :)
Thank you.
You can expand the other code and how to use. simple [N,L], [R]
Thanks a lot bro, exactly what I needed !
thankyou so much
your fucking awesome -auto subscribed. thank you so much.
great tutorial, thanks
thank you so much, you did well
Very Thanks
THANK YOU!
thank you 😘😘
Nice!!!!
Thank you ❤️
hi . thanks . but previous address is still available!! . the question is how can disable or hide previous address? thanks inadvance
Thank you
Thanks!
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'.
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);
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: ^(.*)$
good
the reward goes to you, for such helpful tutorial. Thanks.
tysm
bravo!
Great!
Thanks :)
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
Link between page with css & js has been remove , how to sol ?
(when did /id=something )
Genius
how should i do this for a application consists of 500 php files and directories with sub directories all , this wont work for me
thanks sir finaly i have remove .php but right now i dont change file name please help
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?
When I refresh the page it goes back to original URL. What to do please help :(
this aint working on my localhost..is there something I have to do in order to obtain that?
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
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?
how load image or extenal css file..please help
+entertainment ™
Please explain me on - fb.com/thenishh
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
i am using in my .htaccess file this code RewriteRule ^details/([0-9]+)$ details.php?id=$1 [L] and in href path
my css and images are not working
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
RewriteRule ^user/([0-9]+) user.php?id=$1
Above Code now working , Geting obect not found .
Please let me know the solution
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.
+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...
+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
+Istiaq Hasan
ruclips.net/video/wvmROF0xrVU/видео.html
How to www.tld.com/test.php enter redirect www.tld.com/test ?
+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.
+thenish khan Don't work. /test enter work it. But /test.php display www.website.com/test.php. Don't redirect /test page.
+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...
+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 !
+A.Malik ÖZKİREMİTÇİ
bro this example file. i hope you can understand.
Link - is.gd/urlex
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..
you need put the correct and full address of css, js file
Wrong --> "/css/style.css"
Correct --> "website/css/style.css
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
Again you need put the correct and full address of link
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/">
its not working on local server
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
+Navas Pixelbird
Fix Internal Server Error on wamp : ruclips.net/video/izaD49eYKp4/видео.html
+thenish khan just try this url in your server
localhost/htaccess/user/1/3/4/5/46/5/54/54kjh/43dgsdf
+Navas Pixelbird
got it use ?$ at the end
+Navas Pixelbird
i will try this URL after some days because now i am out of town
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
Don't works for me :/
+Ruben Villegas
what isn't working ?
+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
very simpel to understand good example ;) thank
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]"