How to use .htaccess file inside the folder. I'm using two .htaccess files in my hosting, one for labs.9lessons and another for touch.9lessons. Just take a look at this post how I had implemented.
Original URL : http://www.9lessons.info/touch/index.php?id=srinivas
to
Friendly URL : http://touch.9lessons.info/srinivas
First .htaccess file
This code redirects sub domain http://touch.9lessons.info pointing to touch folder.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^touch\.9lessons\.info$
RewriteCond %{REQUEST_URI} !^/touch/
RewriteRule (.*) /touch/$1
RewriteCond %{HTTP_HOST} ^touch\.9lessons\.info$
RewriteCond %{REQUEST_URI} !^/touch/
RewriteRule (.*) /touch/$1
Second .htaccess file
This file inside the touch directory. Contains single parameter URL rewriting code.
RewriteEngine On
RewriteBase /touch/
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?id=$1
RewriteBase /touch/
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?id=$1
Old Posts about .htaccess
- Redirect The Sub Domain To a Sub Folder with .htaccess
- URL Rewriting Tip with .htaccess File
- Pretty URLs with .htaccess Rewriting Tips.
- Add Security to your PHP projects using .htaccess file
I know that .htaccess is used to password protect pages...this is an addon
ReplyDeleteLike this d(^_^)b
ReplyDeleteI need it ..
thanks for share ..
Hey, nice blog....keep up the good work...i was sitting next to you :) I blog at http://techblissonline.com/
ReplyDeleteHi Srinivas,
ReplyDeleteFirstable I want to thank you for this wonderful tutorials.
I am trying to implement Htaccess example into my localhost, but some how I am not succeeding.
Here it is my url
http://127.0.0.1/mcv/index.php?action=login
I would like to rewrite it into this format
http://127.0.0.1/mcv/action/login
I have been trying a lot of examples but still I am not getting what I need. Even though I could create something similar I had troubles with my css files they are not loading unless i write their url ../../style.css
Any kind of help will convenient.
Thank You.
Dynamikus
Thats simple method to do mod rewrite URL, cool!
ReplyDeleteHi Srinivas
ReplyDeletehow can I change this URL:
www.mysite.com/users/myname
to:
www.mysite.com/myname
I'm triying get rid of users dir using mod rewrite
Hi,my english is not.
ReplyDeletehttp://touch.9lessons.info/srinivas < I do not
http://srinivas.9lessons.info/ < I do
How can I do ?
Your article is so interested and I'm one 9lessons followers
ReplyDeleteI want to make it like that
http://wwww.domaine.com/index.php?id=srinivas
to be
http://wwww.srinivas.domaine.com