mod_rewrite Tutorial for Absolute Beginners

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

03-Jan-10 00:00
This is a forum topic for discussing the article "mod_rewrite Tutorial for Absolute Beginners":

http://www.elated.com/articles/mod-rewrite-tutorial-for-absolute-beginners/

Explains what mod_rewrite is and how to use it. Includes 3 practical examples: 301 redirects, creating friendly URLs, and blocking image hotlinking (leeching).
05-Feb-11 14:10
Hi Matt,

thank you for writing this introduction. After reading over a dozen tutorials on .htaccess and mod_rewrite, this is the first that's able to explain it in clear, normal language.

rgds, Eric
07-Feb-11 20:02
Thanks for your kind words Eric. I'm glad you found the article easy to follow.

Matt

--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/
09-Feb-11 20:01
Hello Matt,
I love this tutorial, so easy to understand. I also have read tutorials on mod_rewrite else where, but you make it perfectly clear.

Thanks again, Joe
09-Feb-11 22:40
Thanks Joe. It's great to know that this article is helping so many people!

--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/
01-Mar-11 16:21
thanks joe, nice introduction;
but... i still have no idea how could i do the following:

a rewrite from subdird.domain.ltd internaly to domain.ldt/index.php ?
so lets say the structure looks like this on my hosting:
/root_www/index.php (we want to rewrite from 3th lvl domain to this)
/subdird/

so when i access in browser subdir.domain.ltd/ it rewrites internaly to domain.ltd/index.php

anyone can help plz?
02-Mar-11 02:44
@webperfection: Something like this perhaps?


RewriteEngine on
RewriteRule ^/?$ /root_www/index.php [L]


--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/
08-Mar-11 09:05
well... life would be 2 easy and boring with solution like that
the thing is that if i enter my 3th lvl domain
3th.domain.ltd
its "impossible" to get out of there
/ == 3th.domain.ltd
with absolute path i cant access anything
cant use ../ ether
once more the folder structure used:

/www_root/index.php (doc root)
/3th/some.html (so to root i tough i can get like ../www_root/ which is impossible)

so following wont help me
RewriteRule ^/?$ /root_www/index.php [L]
coz / is already /var/www/domain/3th/

as i was despaired with no solution i asked my provider to set vhost serveralias to *.domain
and i had to wrote my own php router for everything :/

so my final question would be: is it apache config related problem or just my lack of experience with mod_rewrite?

thx for replay
10-Mar-11 20:53
@webperfection: Sounds like more of an issue with your virtual server. If your apache can't address the path of the site you want to redirect to then there's not much it can do (apart from a 301/302 redirect).

--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/
26-Sep-11 18:29
Hello, Matt

I registered here only to express how grateful I am for you tutorial. I found it very helpful.
The official documentation was too difficult to read for me as an introduction, in other tutorials the processing of the directives wasn't explained clearly enough.
It was a pleasure to read your tutorial. Really well-written. I didn't have to read anything more than once


Really, really grateful and delighted to be finally able to use mod_rewrite,
Michael

[Edited by highlyFlammable on 26-Sep-11 18:30]

--
Michael
28-Sep-11 04:56
@highlyFlammable: Thanks for your feedback! I'm really pleased you found the tutorial useful.

--
Matt Doyle, Elated
3rd Edition of my jQuery Mobile book out now! Learn to build mobile web apps. Free sample chapter: http://store.elated.com/

 
New posts
Old posts

Follow Elated