Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website Design Forum


You are currently viewing our Website Design Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Php to Static - Getting Dynamic Pages Indexed
Old 12-27-2004, 12:35 PM Php to Static - Getting Dynamic Pages Indexed
Junior Talker

Posts: 1
Trades: 0
A simple method to convert files from Php to Html Extensions, on an Apache Server

Most will agree Php has become the common language for creating dynamic Websites. Although the language is simple and efficient, some developers are finding trouble getting traffic to their Php site. It is believed by many educated Search Engine Optimization Specialists that several spiders do not read beyond the, “.php?,” on a URL. Therefore, dynamic pages that pass a variable will be overlooked. For example, on a PHP directory, variables may be passed to a file as, “index.php?category=x”. In this instance, the category specified as “x” will not be read or indexed by some Search Engines. Their Spiders will open the parent page (index.php). This is supported by the belief that nothing is read beyond the “?”, thus making all category links, “index.php”.

While many dynamic Websites still receive modest traffic, it may be in a developers’ best interest to allow some, or all, dynamic pages to be seen as well. Having two pages indexed may not double a sites’ traffic, but it will ensure a noticeable increase. Developers’ can easily overcome this problem, if their Site resides on an Apache Server.

This simple fix will satisfy the problem for a simple script, as in the example above, where one or more Php files are passed variables to perform different functions. Bare in mind, if a Php file only performs one task, this is not required. Files that perform a task without the “?variable=x” being required should be easily indexed. Therefore, it would be useless to transform them to a Static URL (HTML File).

Identify the Php File Needing to be changed to an Html Extension

First, identify the desired file, or files, that require the change, along with the variables that generate a common page. Generally, this may be, “index.php”. To help readers follow along, I am going to utilize the above Directory example. On our Directory program, we have a main page, “index.php,” which always displays links to Subdirectories. The subdirectories are opened by passing a variable to the index file. For example, a subcategory called, “Arts and Crafts,” is displayed with, “index.php?category=1”. Additional subcategories are displayed with an identical syntax, but the end variable changes. Because of this, we need to modify the way our server opens the index.php file, when a variable is attached.

Tell The Server to Open a Php File, when receiving an Html Request

Next, we need to place a simple .htaccess file in the directory where, “index.php,” is located on the server (If one does not exist, otherwise we need to modify the current file as follows). The .htaccess file is a simple text file that we name .htaccess. Vdeck users may need to create a file named something.txt, and then rename the file to .htaccess, if using the admin panel. Now we need to specify some variables to the server. For this example, I am going to change the request, “?category=x,” variable to, “directory-x.html”. This step will eliminate our problem of having the subcategories noticed by some Search Engine Spiders.

To start our server variables, we need to create a rewrite engine in the new .htaccess file. Simply put our first line will read, “RewriteEngine On”. This tells the server we are changing the way certain files are to be handled. Now we need to specify our Rewrite rule. On the next line, with my example, “RewriteRule ^directory-([0-9]*).* index.php?category=$1 [L,NC],”. This is delegating, “requests to this directory, where the file is named, “directory-,” followed by a range of 0 to 9, followed by anything (* = Wildcard) and, “dot,” anything (* = Wildcard), we are going to display, “index.php,” file with the variable attached. We can create another rewrite rule on another line of our .htaccess file. However, a meticulous developer likes to test things out before making changes to the actual Php file, or progressing ahead of oneself. We can test our, “RewriteRule,” by opening another browser window and entering, “directory-1.htm or directory-1.html,” into the address bar. We should see the same page displayed as, “index.php?category=1,” is called.

Getting our new pages seen

Finally, we want the Search Engine spiders to be able to see our shinning new readable URL that can be indexed. Rather than scurrying around to every search engine and submitting the URL, we are going to open up our Php file for editing. Before this is done, make a copy of each script that is going to be modified. Save the copy to the hard drive in a memorable location. Then identify the different areas of the program that create the links being changed. We don’t want to change things on the back-end, just the front-end. The Php file will still be getting the information as, “index.php?category=x,” from the .htaccess file. We want to change the display part that users to the site see. This is where links are dynamically created on the Php Script. We need to replace, “index.php?category=,” to read, “directory-,” where, “index.php?category=X,” is found and follow behind the variable (x) with, “.html”.

Alternatively, simple html included on Php Templates may resolve the issue of getting found. Modify the simple html links to point to the new .html extensions, if experiencing problems modifying the Php code.

Once the area to be modified is deciphered and implemented, check the modification by clicking on links at the Site. If you make a mistake on a script and get ahead of yourself, it may be difficult to fix the problem. Especially if there is little familiarity with Php Coding.

To see this exact modification in action, visit http://links.mjmls.com/index.html. Follow any of the category links on the page. Then change, “directory-,” to, “index.php?cat=,” and drop the html extension. Please note, I am experimenting, that is the reason the index page also has an Html extension. I have not found any reason to suggest this to other developers.

If you have found this information useful, I would appreciate recognition with a modest link to my domain (mjmls.com).
Michael Medeiros is offline
Reply With Quote
View Public Profile Visit Michael Medeiros's homepage!
 
 
Register now for full access!
Old 12-27-2004, 04:11 PM Re: Php to Static - Getting Dynamic Pages Indexed
Junior Talker

Posts: 136
Trades: 0
now this is the kind of user's first post I like to see... thanks for the nice tutorial and welcome to the boards
microski is offline
Reply With Quote
View Public Profile Visit microski's homepage!
 
Old 12-30-2004, 01:38 PM Re: Php to Static - Getting Dynamic Pages Indexed
Banned

Posts: 0
Trades: 0
yep, thanks.
wirlwind1 is offline
Reply With Quote
View Public Profile
 
Old 01-05-2005, 10:12 PM Re: Php to Static - Getting Dynamic Pages Indexed
Junior Talker

Posts: 36
Trades: 0
Which SEs are we talking about? I know Google does fine seeing that almost any forum software passes info via URL, and these pages do show up in Google.

While it is important to try to cater to as many SEs as possible, sometimes it is about balancing this kind of compatibility with other aspects of business that could benefit even more...
bytech is offline
Reply With Quote
View Public Profile Visit bytech's homepage!
 
Reply     « Reply to Php to Static - Getting Dynamic Pages Indexed
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14664 seconds with 12 queries