Jump to content

htaccess - current directory


esahp

Recommended Posts

How would I restrict the entire HTACCESS file (or just certain rules *in* it), to the directory it's in?

For example: /home/blah/public_html/.htaccess - works in /home/blah/public_html but does not work in /home/blah/public_html/boo

My HTACCESS consists of:
[code]
RewriteEngine on
RewriteRule ^id/([^/\.]+)/?$ index.php?id=$1
[/code]
Link to comment
Share on other sites

If you place an .htaccess file in the public_html folder it will work in that folder aswell as any subfolders within the public_html folder too.

Your rewrite rule will work in both directories, however it will differently. For example when u do this:

mysite.com/id/123 it will translate to this: mysite.com/index.php?id=123

However when you do this same when you go to mysite.com/boo/id/123 it will translate to this:

mysite.com/boo/index.php?id=123

In other words if you do mysite.com/ it will use the index.php in the root of the public_html folder whereas mysite.com/boo will use the index.php file in the boo folder and not the index.php in the root of the website (public_html).
Link to comment
Share on other sites

Yeah, I know about that. I spent a few days trying to get that right, and so far so good.

My question is can I do either of these two things with htaccess:

1) Can I make it so certain rules inside the HTACCESS apply to a specificed directory (no more no less)?

OR

2) Can I make it so the entire HTACCESS applies to a certain directory (no more no less)?


* Sorry if that was blunt, trying to make it clear :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.