SharkSpace - Web Hosting with a BITE!

Fun with .htaccess

Posted in Web Design

.htaccess



In a web server, the server’s configuration file normally defines the settings that files and directories in your account follows. However these settings can be customized to an extend by yourself using simple text files called .htaccess. When properly congfirued, .htaccess file can allow you to ,etc. Each line in a .htaccess file is called a directive. Directives are applied to the directory the .htaccess file resides in and any subdirectories within that directory. So if it is placed in the public_html directory, all the files and directories in your account will be affected.



Creating a .htaccess file:



You can create a .htaccess file using any text editor like Notepad (Windows), TextEdit (Mac), vi (Linux), etc.. To create one, open your text editor, enter a few directives and save the file as .htaccess (with the period). If your editor won’t let you save the file as .htaccess, name it htaccess.txt instead. You can rename it after you’ve uploaded it to your server. When uploading the .htaccess file to your server, make sure that it is uploaded in ASCII mode. Some FTP clients may not show the file as files with names that begin with a period are normally considered as hidden files. So you will have to change the settings in your FTP client in that case. If there is an existing .htaccess file, you can just edit it with the required directives.



Even though most of the tweaks can be done using cPanel which uses .htaccess file, a basic understanding of various directives used in .htacess file will give you more control. We will cover some useful stuff that we can achieve using a .htaccess file in this blog:



1) Redirect Traffic:



You can redirect all visitors or certain visitors only based on their IP address, etc.



order deny,allow
deny from all
allow from 72.10.20.30

ErrorDocument 403 /page.html

allow from all



Replace 72.10.20.30 with your IP address. Also replace page.html with the name of the page you want visitors to see.



2) Custom Error Pages:



The web server normally displays a 404 error when it receives a request for an non existant page. You can replace the server’s default error page with one of your own that explains the error in plain language and links visitors to your home page. Here’s how to use your own page:



ErrorDocument 404 /404.html



Replace 404.html with the name of the page you want visitors to see.



3) Redirect Moved pages:



When you move your pages to a new location, the URLs in the index of search engines will not get updated and you will loose traffic when visitors land in the old URL. You can use a 301 redirect to automatically send to the new page when they try to access the old one:



Redirect 301 /old.html http://yoursite.com/new.html



Using a 301 redirect also ensures the page doesn’t lose its search engine ranking.



4) Prevent Directory Browsing:



When there’s no index page in a directory, visitors can look and see what’s inside. This may be insecure as you are exposing hidden content to the public. Some servers are configured to prevent directory browsing like this. If yours isn’t, here’s how to set it up:



Options All -Indexes



5) User Friendly URLs



This one is a bit tricky, but very useful and helps in Search Engine Optimization as well.



For example, your page is at the location:



http://www.domain.com/html/new/contact.html



When it comes to URLs, as long as the meaning is clear, shorter is always better for your visitor and a search bot, like: http://www.domain.com/contact



With htaccess and an Apache module called mod_rewrite, you can set up URLs however you want. Your server can show the contents of “/html/new/contact.html” whenever anyone visits “http://domain.com/contact”. Here are a few examples:



RewriteEngine on
RewriteRule ^contact/$ /html/new/contact.html [L]



These are some of the basic tweaks that you can achive using a .htaccess file. You can find many advanced directives here.



No Comments »

Website Usability and Web 2.0

Posted in Web Design

Websites should be created keeping in mind that it should be useful and helpful for the users or the targeted audience. In other words, websites should be usable. That is where the term Website usability comes up. The crux of making a good website depends on certain features that will draw the users. It should necessarily be clear and should be very user-friendly. A simple navigation (more…)

No Comments »

Web Site Design Essential Tips

Posted in Web Design

One of the best ideas to get a startup website is to simply search on the Internet for anyone offering to build your site for free. You will find lots of freelancers and even companies out there, who will do it for you absolutely free. Many web-hosting companies provide web-designing tools, which you can use to instantly generate great looking sites at a click of few mouse buttons.

Of course it is up to you as to the number of pages you want to have, its content, its theme, the colors, and other details. I would suggest you study at least a dozen quality sites before starting building yours. Nothing can match the fun and satisfaction you are going to have when you complete and launch your own site.

No Comments »

What kind of web design is right for you?

Posted in Web Design

In order to stand out among the huge crowd of websites available on the internet and attract heavy web traffic to your web site, you need to design your web site in a unique and innovative way. (more…)

No Comments »

Hiring a web design company

Posted in Web Design

The primary considerations for choosing a web design company are:
? – Price of product – Does it include the price (more…)

No Comments »

« Previous Entries

Need help ordering?
Please let our sales team help you on Live Chat.
Affiliate Program
Earn up to $100 per sale! No limit on how much you can earn. [Full details]
Free Account Transfers
SharkSpace will transfer your hosting account for free! [Full details]