Home > Archive by category 'htaccess'
 

Redirection of files or folders using htaccess

Some times we require temporary or permanent redirection of files or folders to some other files or folders. There could be any reason, it may be outdated, may be temporary unavailable or any thing. You can use htaccess file to redirect to new destination.

1
Redirect /olddirectory/oldfile.html http://www.domainname.com/newdirectory/newfile.html

Disable directory listing or browsing using htaccess

This simple code will disable all directory listing for any directory. This typically required in apache, cpanel based hosting accounts. By default directory listings are enabled. By using below code you can disable listing of any folder.

1
IndexIgnore *

Show php pages as html

Below code will convert all your php pages to .html page. This is often required when you want to execute php codes but want page extension as .html.

First write all your php codes and save the file as any-name.php. Then put below codes in .htaccess file and you’ll be able to see the file as file as any-name.html.

1
2
3
4
5
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.html $1.php

 
 
 

Categories

Tag