NameSilo

Accesing a file in an upper directory thread

Spaceship Spaceship
Watch
Accesing a file in an upper directory

I am trying to access the .htaccess file from another folder, so for example from the admin folder i want to edit the root .htaccess file.
PHP:
$current = file_get_contents('../.htaccess');
$current .= "\n RewriteRule ^". $url ." show.php?id=". $id;
$h = fopen('../.htaccess', 'w+');
fwrite($h, $current, filesize('../.htaccess'));


I have this but it doesn't seem to work.
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Well your fopen only has one . if you are trying to access from like
/blah/
Where your script is in
/blah/blahs2/

Or are you trying to access where your script is
/blah/
And your .htaccess is in
/blah/blahs/

??

- Steve
 
0
•••
first one.

The file is in /blah/
and script is in
/blah/blahs2/
 
0
•••
.htaccess does not generally have the proper premissions to be edited. You will need to use ftp and php in order to do it.

http://php.net/ftp

Good luck.. I will let you try first before giving you the code for it..

- Steve
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Live Options
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back