What is .htaccess?
Simply put, .htaccess if a file you can create in your document root to do all types of handling on a per-directory basis when your server receives a request. Such handling includes what server features are made available, password authentication, URL rewriting, URL redirecting, etc. Suppose you are a book site and your directory structure looks like this:
/book-name/chapter1/section1/...
You can have .htaccess in /, in /book-name, in /chapter1, etc. each with its own set of configurations that will override the directories higher up in the tree. This allows directory specific configurations. The most common configuration is URL rewriting and URL redirecting.
How do I change Apache .htaccess WITHOUT restarting Apache server?
You do NOT need to restart Apache after you change your .htaccess in order for your change to be reflected. I am using Apache/2.0.52 (CentOS) Server and this is true in this server. If you misconfigure .htaccess you'll see 500 Internal Server Error after you reload the page. For a comprehensive tutorial visit Apache Tutorial: .htaccess files
How do I quickly 301 redirect a page to another with .htaccess?
Easy. You simply add the following code in .htaccess:
RewriteEngine on
RewriteRule old-page.html$ http://new-site.com/new-page.html [L,R=301]
Once you save it refresh old-page.html and it should 301 redirect to http://new-site.com/new-page.html. Before you can do that you need to make sure the mod_rewrite module has been installed and enabled on your Apache server. Most likely this is true. For a comprehensive tutorial on the module visit Apache module mod_rewrite
How come my .htaccess does NOT work?
If after you edit .htaccess you don't get the desired effect, then most likely AllowOverride is messing things up. You may have "AllowOverride None" somewhere up in the hierarchy that makes Apache ignore your .htaccess in question. One quick way to find out is put junk in .htaccess and fresh your page. If you get no error, that means Apache is ignoring it and you almost certainly have "AllowOverride None" in effect. If you get errors, that means Apache is accessing it and you'll need to fix the errors. In either case check error log or ask your administrator if you don't have such access.
Senin, 01 Februari 2010
Langganan:
Posting Komentar (Atom)
0 komentar:
Posting Komentar