Skip to content

Instantly share code, notes, and snippets.

@reconbot
Created March 17, 2009 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reconbot/80240 to your computer and use it in GitHub Desktop.
Save reconbot/80240 to your computer and use it in GitHub Desktop.
local edit .htaccess
<html>
<head>
<title>.htaccess Editor</title>
</head>
<body>
<center>
<br /><br />
<h1>.htaccess Editor</h1>
<br />
<b>This is a php based .htaccess editor. Its probably a bad idea. but at least you have to be from localhost.</b>
<br /><br />
<?php
if ($_SERVER['REMOTE_ADDR'] == "127.0.0.1" || $_SERVER['REMOTE_ADDR'] == "::1")
{
if ($_POST) //if we're posting changes
{
// write the changes
$directives = $_POST['code'];
$file = fopen(".htaccess","w+");
fputs($file, $directives);
fclose($file);
}
$file = fopen(".htaccess","r+") or exit("Unable to open .htaccess");
$directives = fread($file, filesize(".htaccess"));
fclose($file);
} else {exit( "Access Denied for " . $_SERVER['REMOTE_ADDR']);}
?>
<form name = "htedit" METHOD="post">
<TEXTAREA NAME="code" ROWS=6 COLS=40>
<?php echo htmlspecialchars($directives); ?>
</TEXTAREA>
<br />
<INPUT TYPE="submit">
<INPUT TYPE="reset">
</form>
</center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment