Some days back I had posted "Pretty URLs with .htaccess rewriting tips". In this post I had given one more pretty URL tip with .htaccess tip. I hope it's useful for you.
Book : The Definitive Guide to Apache mod_rewriteThe Definitive Guide to Apache mod_rewrite
Original URL:
Eg:http://twitter.com/followers.php?id=9lessons
Rewriting URL
Eg:http://twitter.com/9lessons/followers
.htaccess Code
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)/\followers$ followers.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/\following$ following.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/\followers$ followers.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/\following$ following.php?id=$1
nice :)
ReplyDeletei made one small demo from your twitter search box ;)
http://ajax.chadan.in ( ignore some design errors )
@Chandan
ReplyDeleteDemo link not working
Nice article but expand this tutorial like id=9lessons&sub=20&....
ReplyDeleteum, the rewrite rule should be":
ReplyDeleteRewriteRule ^([a-zA-Z0-9_-]+)/\followers$ following.php?id=$1
for the URL: http://twitter.com/9lessons/followers
Just to share I site i used as reference
ReplyDeletehttp://www.easymodrewrite.com/
@Av4tar
ReplyDeleteNice link.
Hi,
ReplyDeleteI have some basic knowledge about how to url rewrite, but there is something I hope u can clarify:
What I want is a url
www.abc.com/software
go to
www.abc.com/index.php?cat=software
I see a lot of examples that show: www.abc.com/folder/one
matching with rewrite rule going to subfolder 'folder' but I want it to be rewritten to the index of the root.
Or is there sumthing I'm missing out?
Thanx in advance
Try this:
ReplyDelete^([A-Za-z0-9_-]+)$ index.php?cat=$1
Of course, this will treat any data trailing your '.com' as the category for your index.
Thanks dude....you solved my problem...
ReplyDeletehow to sett if it addon domain?
ReplyDeletehi
ReplyDeletei can't run at localhost.
Which server do you use?
can help you.
i want to make all the links like www.domain.com/user
ReplyDeleteuser=several names and change by user.
redirecto to usr/index.php?usr=user
This is called human-friendly URL (HFU), because
ReplyDeleteman it is easier to remember or write
VERY NICE POST
ReplyDeletecool!!
ReplyDeletei want to hide the extension of a file on url after clicking it.
ReplyDeleteI want to click a link and it shows onl thefile name without the extension in url.
ReplyDeleteI want rewrite url : http://test.com/?t=content/>^*&id=1&page=1
ReplyDeleteto http://test.com/content/>^*---1--page-1
http://localhost/Tagsoft1%28new%29/service_leftmenu.php?id=17
ReplyDeletei want
http://localhost/Tagsoft1%28new%29/service_leftmenu/17
by .htaccess and what changes should i do in my page links and menu
Hi, In my case it is working fine username.domain.com how can i change it to domain.com/username
ReplyDeleteHi can you help me to write .htaccess file. I need to rewrite url as follows
ReplyDeletehttp://www.example.com/en/show?website=google
to
http://www.example.com/en/website/google
any chance
nice script,
ReplyDeleteany one know that how can i remove index.php from url joomla 1.5 version.
I'm also used the sef setting but it's not working well and produced the 404 error.
Please help me!!!!!
Thanks
it worked , but with this my submit form dosent work as followers.php?id=$1 itworks well bu no with /9lessons/followers
ReplyDeleteHello admin your code it not work how can i do admin ?
ReplyDeleteHi sir!
ReplyDeletePls help me how can i rewrite my urls fr0m
www.site.com/exploits.php?id=1
to
www.site.com/exploits/1
i vil be very thankful to yew!
hai,
ReplyDeletejquery is working in
http://www.mysite.com/content.php?maincategory=software&sucategory=msoffice
jquery is not working htaccess rewrite url
example => http://www.mysite.com/software/msoffice
can you help to fix this....thanks
Hi
ReplyDeleteI want to convert my URL from
http://mywebsite.com/microsite.php?action=PTU
To
http://mywebsite.com/PTU .
Please help me..
Thanks in advance
which one is correct .htaccess or htaccess.?
ReplyDeleteCreate file as .htaccess
ReplyDeleteHi
ReplyDeleteI want to convert my URL from
http://mywebsite.com/Discussion/index.php?qid=15
To
http://mywebsite.com/Discussion/56 .
Please help me..
Thanks in advance
RewriteRule ^Discussion/([0-9]+)$ index.php?qid=$1
ReplyDeleteRewriteRule ^Discussion/([0-9]+)/$ index.php?qid=$1
sir please help
ReplyDeletehttp://mysite.com/web-site.php?pid=good-web
I Create file .htaccess
RewriteRule ^web-site/([a-zA-Z0-9_-]+)$ web-site.php?pid=$1
RewriteRule ^web-site/([a-zA-Z0-9_-]+)/$ web-site.php?pid=$1
Please help .
Thanks in advance
really amazing blog.
ReplyDeleteMicrosoft office 2007 key
http://sourabhgupta.com/onlinelearning_dbms
ReplyDeleteSir i want to show this url like
http://sourabhgupta.com/view_project/onlinelearning_dbms
How can i do that