I used the URL trick of the article http://www.phpbuilder.com/columns/tim20000526.php3. In that article, he explains how to force a php script without a .php extension to run using the htaccess file. Then the variables are processed to make the url a more search engine friendly one. Example. Instead of http://www.localhost.com/local.php?country=US&state=AL&city=Birmingham , a url would say http://www.localhost.com/local/US/AL/Birmingham thus making it look like a static page.

Now to do this he explodes the URL to get the variable out. What I want to do is change the separating character from a slash to a dash (-). The reason being, is because of a discussion I had with a SEO company that said that webpages that appear in the root directory or next one up, will have a better chance at high rankings. Any I want my url to look like this instead...

http://www.localhost.com/local-US-AL-Birmingham

That way, it appears to be a root level page. I would also (not essential to take it this far, but would be even better) like to make the Birmingham variable say Birmingham.htm in my MYSQL data table.
http://www.localhost.com/local-US-AL-Birmingham.htm

Any ideas on this, php programmers? I am new to this stuff and I tried to add the - and could not get it to read... Here is what I tried in the file that is named 'local' ... (the '/' works but '-' doesn't so far)...

<?php
$url_array=explode("-",$REQUEST_URI); //BREAK UP THE URL PATH
// was USING '/' as delimiter changed to '-' but no luck
$url_category=$url_array[2]; //Which country?
$url_subcategory=$url_array[3]; //Which state?
$url_product=$url_array[4]; //Which Major City ?

if($url_product) {
include('include/city.inc');
exit;
} elseif ($url_subcategory) {
include('include/state.inc');
exit;
}
elseif ($url_category) {
include('include/country.inc');
exit;
}
else {
Header ( "Location: index.html");
exit;
}
?>

    <?php
    $url_array=explode("-",$REQUEST_URI);
    print_r($url_array);
    ?>

    when you see the output of the above code, you will know what variables you will need to use 🙂
    and what other changes you will need to make in the script to get it to work 🙂

      I changed my script to say that. And it could not find the page when I typed in Http://www.mywebsite.com/shop-Auto-Tire

      But when I typed in the url this...
      http://www.mywebsite.com/shop/Auto-Tire
      I get this...
      Array ( [0] => /shop/Auto [1] => Tire )

      If I type in http://www.mywebsite.com/shop/Auto-Tire-Crowbar
      I get this...
      Array ( [0] => /shop/Auto [1] => Tire [2] => Crowbar )

      When the old method is typed in...

      http://www.mywebsite.com/shop/Auto/Tire/Crowbar
      I get this..
      Array ( [0] => /shop/Auto/Tire/Crowbar )

      I am not completely sure what this means exactly but that it is an array (but that is not pure genius on my part :-) Anyway, I will study up on this and see what I can do.

      Do you think that there will be any way to make the url display like... http://www.mywebsite.com/shop-Auto-Tire-Crowbar or am I barking up the wrong tree?

      Is it impossible to do? .. This is what I am asking.

        It is very possible using the method you've used. Try doing this:

        print_r ($_SERVER);

        to see which variables pick up the entire string, and what they look like.

        On another note, your SEO company is more than likely flat-out wrong in telling you that pages that appear in the root directory rank higher. MOST search engines will openly state that this is NOT the case, specifically Google answers this question almost every year at the Search Engine Strategies EXPO. Every year they say the same thing:

        " No, how many levels deep in the directory structure does not affect ranking. HOWEVER, USUALLY a page that is many levels deep also doesn't have any links from the homepage or other main landing pages, so it takes a long time for our spiders to find them because they have to dig several levels deep through links, and they usually get indexed less frequently. If you have links to those pages on your homepage, they'll get indexed and ranked appropriately. "

          on an appache system the fp xtensions already rewrite a bunch of rules. You probably just overwrote one of their rewrites. I wouldn't worry too much since fpe suck anyway.

            10 days later

            Is it possible though? I noticed it does not let me log into the online web or even edit any pages on the site unless I remove the script from the htaccess file.

            I am still interested however in the method of the url looking like... http://www.mywebsite.com/shop/Auto-Tire
            since it seems that the method at http://www.programmingtalk.com/showthread.php?t=3124&goto=newpost has worked but at the expense of the use of Frontpage Extensions. If anyone can figure that one out I would appreciate it.

              Write a Reply...