How to Make my web site popular with search engines
- Open Notepad on your Windows machine (or a comparable text editor if you're using a Macintosh). Avoid using MS Word or any type of word processor because these programs add extra formatting characters by default that will cause problems.
- Copy and paste the following text into Notepad:
RewriteRule ^productid([^.]+).*$ yourscript.php?id=$1 [T=application/x-httpd-php]
- Change /basedir to the name of the directory containing your dynamic pages. This will normally be just a "/" unless the pages are in a subdirectory, in which case it would be a "/" followed by the name of the subdirectory.
- In the "RewriteRule" line, after the question mark, change "id" to whichever variable you're using to pass your product id in order to display the product detail page. Navigate to the link on your site that displays a product detail page from your database. Study the URL in your browser. Normally you'll only have a question mark followed by the product ID. However, if other parameters exist, you'll need to rewrite those too.
- In the "RewriteRule" line, change yourscript.php to the name of your dynamic product detail page. This will be the script name seen in the URL often ending in ASP, PHP, or various other extensions. The script name will normally precede the question mark.
- If your site does not use PHP, change "T=application/x-httpd-php" to the MIME type for the language that you use.
If you have questions, the technical documentation for the mod-rewrite functions can be found at: http://httpd.apache.org/docs/mod/mod_rewrite.html
- Save the file to your local computer. Name it htaccess.txt.
- Upload the file to your Web site in ASCII mode.
- Configure your FTP program to display hidden files. Hidden files are files that start with a dot on UNIX or Linux based operating systems. Most FTP programs have an option to display hidden files either on the preference screen or in the settings for the individual FTP site. Some FTP programs will allow you to add parameters to the list command that will display hidden files. In that case, the parameter that you would need to add to the ls command is "-al" (without the quotes).
- Test your FTP program to make sure you can view hidden files. Try renaming a non-essential file on your Web site to a filename that starts with a dot. Make sure that it shows up in the directory listing. Then make sure you can rename it back to its original file name.
- Rename htaccess.txt to .htaccess (starts with a dot, and no file extension). This will activate your changes.
If you set things properly, at this point your web server will automatically rewrite URLs of the format: http://www.yourWeb site.com/yourscript.php?id=123 to: http://www.yourWeb site.com/productid123.htm
The rewriting takes place behind the scenes, so the URL in the address bar will always display in the new format, without the question mark.