You can check if .htaccess file is present or not by this php file.
- Page redirection
- Access control
- Content protection
- Hot link prevention
- Cache control
- Server side error handling
- Rewrite url
- Set server time zone
Create .htaccess file in your folder. It would be better to create the file using a text editor in windows. Remember: This commands are case sensitive and should not be tempered unnecessarily.
RewriteEngine On
Redirect 301 /http:domain-name.extension
This will redirect you to your desired domain in case you changed your previous domain or you want to go user in different path.
RewriteEngine On
AuthType Basic
AuthName "Restricted Content"
AuthUserFile absolute-path\.htpasswd
Require valid-user
None without a proper credentials can acces into this path. The creadentials will be written in .htpasswd file. You haveto provide proper or absolute path of .htpasswd file in order to get access credentials. On .htpasswd file user and password are written as a format-
user-name:password
<FilesMatch "\.(file-ext|file-ext|file-ext|file-ext)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
On the first line shows, file name extensions should be written in order to choose the type of files will be stored in cache. Max-age derives the time cache will be stored. The time is calculated in second here. After this time stored cache file will be destroyed automatically.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC, L]
RewriteRule ^keyword index.php
In liew of index.php you can write keyword in url to access index.php file. You can add multiple keyword to this path.
options +Indexes =>grant access
options -Indexes =>access forbidden
In order to change access permission of app or any valuable folder to users jusht switch - or + symbol.
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Using this two lines will redirect your http url to https url. Post your http hort url and request url in place
Order allow, deny
deny from the-ip-to-block
deny from the-ip-to-block
allow from all
Using this lines only given IP will be blocked to get access.
RewriteEngine on
RewriteCond %{HTTP_REFERER} domain1.com [NC, OR]
RewriteCond %{HTTP_REFERER} domain2.com [NC, OR]
RewriteRule .* - [F]
Then mentioned domain won't get straight access in this case.
AddHandler server-parsed .html
SSI also called "Server Side Includes" are directives that are placed in HTML pages, and evaluated on the server while the pages are being served. It could be very useful to create some content's dunamically.
SetEnv TZ America/Chicago
TZ could be added as a global envirenment variable to that are provided by the servers to eache of the hosted websites for modification.
ErrorDocument 404 /404.ph or 404.html
In case of any error occurs, this will redirect users to the custom 404 page.
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /mvc/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
Here RewriteBase works quiet similar to of html.
Licenced under MIT license.