Forum Moderators: coopster

Message Too Old, No Replies

php address for htaccess file

         

revrob

9:49 am on Apr 12, 2008 (gmt 0)

10+ Year Member



I've just changed hosts, and am having trouble trying to alter my bot traps so they can write to .htaccess - because I can't get the path to htaccess right, when the bot trap scripts are in a sub directory of my site.

The trap works fine in root, and writes a deny from statement to the .htaccess file, and sends me an email, and bans the IP, but in a sub directory it sends the email but won't write to the .htaccess file presumably because it can't find it.

On the old host I knew what the address was for the root, to get the trap to work, which was quite complicated and not intuitive.
How can I find out the address for my new hosts root?

I've tried /.htaccess and [mydomain.org.uk...] and [mydomain.org.uk...] and none of those work.

The logs don't give me any clues either.

In my ftp settings the path for the root is just /

Any help welcome including where to look.

Many thanks.

[edited by: coopster at 5:02 pm (utc) on April 12, 2008]
[edit reason] removed hosting specifics [/edit]

tutorial

1:18 pm on Apr 12, 2008 (gmt 0)

10+ Year Member



You could try with '../.htaccess'. It will go to root folder and then try to find .htaccess.

coopster

5:05 pm on Apr 12, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The DOCUMENT_ROOT can be found in your $_SERVER superglobal.
<pre> 
<?php print_r($_SERVER); ?>
</pre>

You will see the full path to your document root in $_SERVER['DOCUMENT_ROOT']

revrob

5:29 pm on Apr 12, 2008 (gmt 0)

10+ Year Member



Coopster - thanks. I created a php file "superglobals"as suggested - and got this line (numbers anonymised to ********)
[DOCUMENT_ROOT] => /kunden/homepages/*/**********/htdocs/superglobal.php

so presume I can use
/kunden/homepages/*/**********/htdocs/
as the path?

I'll also try your suggestion Tutorial - thanks.

revrob

5:37 pm on Apr 12, 2008 (gmt 0)

10+ Year Member



tutorial - ../.htaccess did the trick just fine. Thanks again!