Htaccess File Inside The Folder.
Wall Script
Wall Script
Wednesday, March 17, 2010

Htaccess File Inside The Folder.

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.


Htaccess File Inside The Folder.

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

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

Old Posts about .htaccess
  1. Redirect The Sub Domain To a Sub Folder with .htaccess
  2. URL Rewriting Tip with .htaccess File
  3. Pretty URLs with .htaccess Rewriting Tips.
  4. Add Security to your PHP projects using .htaccess file


web notification

8 comments:

  1. I know that .htaccess is used to password protect pages...this is an addon

    ReplyDelete
  2. Like this d(^_^)b
    I need it ..
    thanks for share ..

    ReplyDelete
  3. Hey, nice blog....keep up the good work...i was sitting next to you :) I blog at http://techblissonline.com/

    ReplyDelete
  4. Hi Srinivas,
    Firstable 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

    ReplyDelete
  5. Thats simple method to do mod rewrite URL, cool!

    ReplyDelete
  6. Hi Srinivas

    how 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

    ReplyDelete
  7. Hi,my english is not.

    http://touch.9lessons.info/srinivas < I do not

    http://srinivas.9lessons.info/ < I do

    How can I do ?

    ReplyDelete
  8. Your article is so interested and I'm one 9lessons followers
    I want to make it like that
    http://wwww.domaine.com/index.php?id=srinivas
    to be

    http://wwww.srinivas.domaine.com

    ReplyDelete

mailxengine Youtueb channel
Make in India
X