The .htaccess
file (short for "hypertext access") is a configuration file used by web servers running the Apache HTTP Server. It allows website administrators to control and configure various server settings without needing to modify the main server configuration file. This file is placed in a directory on the web server, and its settings can affect that directory and its subdirectories.
Here are some common uses of .htaccess
:
-
Redirects: You can set up 301 or 302 redirects to move traffic from one URL to another.
-
URL Rewriting: Through mod_rewrite, you can rewrite URLs, creating cleaner, more user-friendly, and SEO-friendly URLs.
-
Access Control: You can restrict access to certain files or directories, such as password protection or blocking specific IP addresses.
-
Custom Error Pages: You can define custom error pages for various HTTP status codes, like 404 (not found) or 500 (server error).
-
Enabling or Disabling Features: You can enable or disable certain Apache features, such as directory listings or caching.
-
Security: It can be used to protect your website by limiting access to sensitive areas, preventing hotlinking, or blocking malicious requests.
It is important to note that incorrect configuration of .htaccess
can lead to server errors or security vulnerabilities, so it should be used with caution.
100% working code of htaccess file for a PHP Website.
Source Code: .htaccess
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA]
For practical example of using of htaccess file with php website please download complete source code of my new project from download link.
This comment has been removed by a blog administrator.
ReplyDelete