Home arrow Web Services arrow Page 3 - Make Dynamic URLs Search Engine Friendly
WEB SERVICES

Make Dynamic URLs Search Engine Friendly


Using a database to dynamically create web pages makes for a much improved site in many ways. However, such URLs are not very search engine friendly. Search engines are much better at indexing static pages, and don't do a good job of following hyperlinks that contain query strings. The advantages of a dynamic site are overwhelmingly obvious--so what is to be done? With a little extra effort, you can create a dynamic site that is easily crawled by webbots.

Author Info:
By: Peter Lavin
Rating: 4 stars4 stars4 stars4 stars4 stars / 69
March 01, 2004
TABLE OF CONTENTS:
  1. · Make Dynamic URLs Search Engine Friendly
  2. · Check Your Server
  3. · Create an .htaccess File
  4. · Upload .htaccess to Your Server
  5. · Test the Results
  6. · Modifying Your Code
  7. · Conclusion

print this article
SEARCH DEVARTICLES

Make Dynamic URLs Search Engine Friendly - Create an .htaccess File
(Page 3 of 7 )

Open the source code of a page on your site and find an URL with a query string similar to the following:

http://www.mysite/main.php?category=$category&subject=$subject

If your URL is relative, rather than absolute, change it to an absolute URL and then copy it to the clipboard. You will have a much clearer understanding of what’s happening if you do it this way. Now open your browser and go to webmaster-toolkit.com.

[Editor's note: A great resource for Search Engine Optimization techniques and tools can be found at http://www.seochat.com.]

Take a moment to appreciate what is available here. I’m sure you’ll want to return, so bookmark the site.

On the left, under the “SEO Tools” heading find and click the link “Rewrite Rule Generator”. Scroll down until your screen looks like this:

Make Dynamic URLs Search Engine Friendly

Now paste your dynamic URL into the appropriate textbox and decide if you want to represent your dynamic URL as a page or a directory. It’s up to you but make sure that you don’t create a directory name that matches an existing directory and that you don’t generate a page name that is longer than 255 characters. If you choose to generate a page name set the appropriate radio button and enter a page name into the textbox (something that best describes your page). We will be using the page name style of static URL in our examples. Click the generate button and you should have your .htaccess file in seconds. Copy the returned text area and paste it into your favorite text editor. The text returned when entering the word “type” into the page named textbox and using our example URL,

http://www.mysite/main.php?category=$category&subject=$subject

is as follows:


Options +FollowSymLinks
RewriteEngine on
RewriteBase 
/
RewriteRule type
(.*)-(.*).htm$ /main.php?category=$1&subject=$2

This is all you will need for your .htaccess file. This file will intercept all page requests within the directory in which it is located and convert specified URLs with a static format to ones using a query string. That may sound like the opposite of what you want to achieve. Read on and things will become clearer.

As promised, you’ve now created a .htaccess file without any reference to regular expressions. Don’t leave the webmaster-toolkit site just yet. Have a look at what the rewritten URL should be. Our example looks like this:

http://www.mysite.com/type\$category-\$subject.htm

Copy it into a text file, remove the backslashes that precede each dollar sign and save it to a text file called format.txt. You’ll need this when revising your PHP scripts.


blog comments powered by Disqus
WEB SERVICES ARTICLES

- Dealing with Loose Coupling in a Service-Ori...
- Loose Coupling in a Service-Oriented Archite...
- Safety, Idempotence, and the Resource-Orient...
- The Resource-Oriented Architecture in Action
- Features of the Resource-Oriented Architectu...
- The Resource-Oriented Architecture
- Getting Started with Flex
- Automated Billing and Faxing for the Web
- An Introduction to Web Services
- The Foundations of Web Services: From Novice...
- Web Services Reengineering: Finishing Touches
- Fault Handling with Web Services
- Flow and Web Services
- Process Lifecycles and Web Services
- Business Processes and Web Services

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials