-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhtaccess-editor.php
141 lines (131 loc) · 6.19 KB
/
htaccess-editor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
require("core.php");
head();
if (isset($_POST['ht-edit'])) {
$fn = $_SERVER['DOCUMENT_ROOT'] . "/.htaccess";
@chmod($fn, 0777);
@$file = fopen($fn, "w+");
fwrite($file, $_POST['htaccess']);
fclose($file);
}
?>
<div class="content-wrapper">
<!--CONTENT CONTAINER-->
<!--===================================================-->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0 text-dark"><i class="fas fa-columns"></i> .htaccess Editor</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="dashboard.php"><i class="fas fa-home"></i> Admin Panel</a></li>
<li class="breadcrumb-item active">.htaccess Editor</li>
</ol>
</div>
</div>
</div>
</div>
<!--Page content-->
<!--===================================================-->
<div class="content">
<div class="container-fluid">
<?php
$htaccess = $_SERVER['DOCUMENT_ROOT'] . "/.htaccess";
if (!file_exists($htaccess)) {
echo '<div class="alert alert-info">
<strong>.htaccess</strong> file was not found on your website and will now be created in the website\'s root folder - <strong>' . $htaccess . '</strong> .
</div>';
$content = "";
@chmod($htaccess, 0777);
$fp = fopen($htaccess, "w+");
fwrite($fp, $content);
fclose($fp);
}
?>
<div class="row">
<div class="col-md-9">
<div class="card">
<div class="card-header">
<h3 class="card-title">.htaccess Editor</h3>
</div>
<div class="card-body">
<form method="post">
<div class="row">
<div class="col-md-8">
<textarea class="form-control" name="htaccess" rows="25" type="text"><?php
$htaccess = $_SERVER['DOCUMENT_ROOT'] . "/.htaccess";
@chmod($htaccess, 0777);
echo file_get_contents($htaccess);
?></textarea>
</div>
<div class="col-md-4">
<p>Please double check them before saving as a mistake could make your website inaccessible.</p>
<ul class="description">
<li><a href="https://www.google.com/search?q=htaccess+tutorial" title="Search for htaccess tutorials" target="_blank">
<img width="16px" src="http://google.com/favicon.ico" alt="google favicon"> htaccess tutorial</a>
</li>
<li><a href="https://httpd.apache.org/docs/current/howto/htaccess.html" title="Read about htaccess at apache.org" target="_blank">
<img width="16px" src="http://apache.org/favicon.ico" alt="apache favicon"> htaccess</a>
</li>
<li><a href="https://httpd.apache.org/docs/current/mod/mod_rewrite.html" title="Read about mod_rewrite at apache.org" target="_blank">
<img width="16px" src="https://apache.org/favicon.ico" alt="apache favicon"> mod_rewrite</a>
</li>
</ul>
</div>
</div>
</div>
<div class="card-footer text-right">
<input class="btn btn-flat btn-primary" type="submit" name="ht-edit" value="Save all changes">
</div>
</form>
</div>
</div>
<div class="col-md-3">
<div class="card">
<div class="card-header">
<h3 class="card-title">Information & Tips</h3>
</div>
<div class="card-body">
A .htaccess (hypertext access) file is a directory-level configuration file supported by several web servers, that allows for decentralized management of web server configuration. They are placed inside the web tree, and are able to override a subset of the server's global configuration for the directory that they are in, and all sub-directories.
</div>
</div>
<div class="card">
<div class="card-header">
<h3 class="card-title">Common Usage</h3>
</div>
<div class="card-body">
<ul>
<li><strong>Authorization, authentication</strong></li>
A .htaccess file is often used to specify security restrictions for a directory, hence the filename "access". The .htaccess file is often accompanied by a .htpasswd file which stores valid usernames and their passwords.
<li><strong>Rewriting URLs</strong></li>
Servers often use .htaccess to rewrite long, overly comprehensive URLs to shorter and more memorable ones.
<li><strong>Blocking</strong></li>
Use allow/deny to block users by IP address or domain. Also, use to block bad bots, rippers and referrers. Often used to restrict access by Search Engine spiders
<li><strong>SSI</strong></li>
Enable server-side includes.
<li><strong>Directory listing</strong></li>
Control how the server will react when no specific web page is specified.
<li><strong>Customized error responses</strong></li>
Changing the page that is shown when a server-side error occurs, for example HTTP 404 Not Found or, to indicate to a search engine that a page has moved, HTTP 301 Moved Permanently.
<li><strong>MIME types</strong></li>
Instruct the server how to treat different varying file types.
<li><strong>Cache Control</strong></li>
.htaccess files allow a server to control caching by web browsers and proxies to reduce bandwidth usage, server load, and perceived lag.
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<!--===================================================-->
<!--End page content-->
</div>
<!--===================================================-->
<!--END CONTENT CONTAINER-->
</div>
<?php
footer();
?>