Home Page of Evan Islam
 
Bookmark and Share
Web Designer in Connecticut >> Web >> Customized Htaccess File
Last Updated: 2009/01/21 9:42:27am

 

Some useful SEO tips and tricks using .htaccess file

Most experienced webmasters will tell you that .htaccess files are really cool. If your site runs on Apache server then try some of these .htaccess command lines...

First create a file on your notepad or any text editor called htaccess.txt (since .htaccess is not a common file extensions, your text editor may not allow you to create .htaccess extension). Then go to your documents folder and rename that file to .htaccess.

I wrote a detailed google knol on .htaccess file with lot more tips and tricks... make sure you check that out.

 

301 Redirect flat URLs using .htaccess

This is very handy if your old page has moved and you want search engine credit for that old page passed on to the new page.

redirect 301 /MyOldPage.html http://www.EvanIslam.com/MyNewPage.html

 

301 Redirect Dynamic URLs using .htaccess

Now, lets say you have page with php variable. content.php?page=MyOldPage and you want to send that page to MyNewPage.html... you can do that very easily with the following

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/content.php?page=MyOldPage$ [NC]
RewriteRule . /MyNewPage.html [R=301]

 

URL Rewrite for dynamic php variable pages

Okay this is cool for SEO. Lets say you have a page content.php?page=MyNewPage and after much study, it is certain that search engines love FLAT web pages more then get veriable pages such as ?variable=value. So, in this case, we need to transform that content.php?page=MyNewPage TO page-MyNewPage.html.

Options +FollowSymLinks
RewriteEngine on
RewriteRule page-(.*)\.html$ content.php?page=$1
What's happening here is that (.*) is replacing ANY values that variable "page" has. So, if you have ?page=somethingelse, your new url will be page-somethingelse.html. You can also create any extension you want... replace \.html with \.dingdong. You page will noe be page-somethingelse.dingdong and it will work :)

 


Comment by Jewel
2008/07/09 01:21:09 PM
Nice


Comment by movers
2010/05/11 11:49:13 PM
I am impressed by reading your article. These are great tips. I really enjoyed the post! thanks for sharing helpful tips. :)


Comment by anna
2011/02/06 07:02:31 PM

you can read more also in an interesting post http://blog.bitlogic.biz/2010/12/seo-some-useful-tips/


Comment by Evan
2011/08/08 09:38:12 PM

Amit, try this:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*).html$ index.php?category=$1

Check this out for more: http://knol.google.com/k/evan-islam/htaccess-tips-and-tricks/2tdhgcs94047p/3#


Comment by Amit
2011/05/22 05:25:46 PM

I have 1 query about rewrite. I want to use http://example.com/1234 instead of http://example.com/index.php?category=1234. How can I do this??

Previous Page

Got any Comments?

Your e-mail:

Your Name:

Website:

Type verification image:
verification image, type it in the box

Comment About This picture:

Evan Islam

My Portfolio
Facebook Graffiti Images
Drawings and Sketches
3D Modeling
Web Design
Connecticut Web Design
Scripts & Tutorials

About Evan
Connect with me on the web
Job History
My Blog
Reviews
My Friends
Calendar
Contact Me

Book Marking Sites
RSS FEEDS