Evan Islam Logo
Call Me 469-382-4544

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.

 

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 now be page-somethingelse.dingdong and it will work :)

Arrow