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
https://forums.phpfreaks.com/topic/30097-htaccess-current-directory/
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).
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 :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.