Basic htaccess

htaccess is a distributed configuration file of Apache Server. it provides a way to configure our changes as per our diretory.
the htaccess file must have existed to the root directory.

The WordPress uses htaccess file to manipulate all URL. every time “htaccess” file is modified when we update permalink structure.
Below is the WordPress Default “htaccess” file content.

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

We can use “htaccess” for below-listed tasks.

-> We can use it in Error documents
-> Redirects URL
-> Make site as a Password protected
-> IP address Deny on our server
-> referrer visitors Deny on our server
-> Browsers and ‘bad bots’
-> Manipulating MIME types
-> Disable directory listings
-> Server timezone
-> Prevent access to php.ini
-> Ensuring media files

Below are the useful mod_rewrite RewriteRule EXAMPLES which you can use on your website.

Example:
Actual URL: http://mysite.com/faq.php?page=1
Rewritten on: http://mysite.com/faq/page/1
.htaccess RULE:

RewriteEngine On
RewriteRule ^faq/page/([0-9]+)?$ /faq.php?page=$1 [L]

Example category page:
Original URL:http://mysite.com/faq.php?category=english
Rewritten URL:http://mysite.com/faq/category/english
.htaccess RULE:
RewriteEngine On
RewriteRule ^faq/category/([a-zA-Z0-9]+)$ /faq.php?category=$1 [L]

Hope this blog will helpful for you. if you have any query on it then please do write the comment, Sure, I will get back to you soon.

Thanks

Advertisements

Say your thought

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s