1

I run an information repository website, catering specifically to CPUs, and before the website gets too large, I would like to know if the current setup is going to give me trouble in the future.

Say I have a directory for Skylake-based Intel Core i7 and legacy Pentium processors. At the moment, this is how the directory structure looks:

/core-i7/
    /i7-6000/
        /i7-6700/
            index.php
        /i7-6700k/
            index.php
        /i7-6700t/
            index.php
        index.php
    index.php

/pentium-legacy/
    /75-mhz/
        index.php
    /100-mhz-15-w/
        index.php
    /100-mhz-17-w/
        index.php
    /133-mhz/
        index.php
    index.php

As you can see, the actual directories for each model are one-file directories. And this applies to all processors in the database. As the database expands, this will of course grow considerably (I estimate around 5,000 models), so before any of that takes place, I'd like to know if the following method would be better for any reasons at all, be it server-related, SEO-related, whatever you think will impact the website in any way.

Okay, here is the structure I'm thinking about using:

/core-i7/
    /i7-6000/
        i7-6700.php
        i7-6700k.php
        i7-6700t.php
        index.php
    index.php

/pentium-legacy/
    75.php
    100-15w.php
    100-17w.php
    133.php
    index.php

Of course, I can already see at least one benefit from this method, and that is with so many index.php files open in Notepad++, it's difficult to know which one belongs to what model until you get to it and check the path, but is there any benefit for the website?

The website's content is mostly a year old, so that's why I bring SEO into this. It would likely take a while for Google to fix the search result URLs. I'm willing to accept this if there are any other greater benefits.

Edit

I'm assuming that the file system is ext3, although I'm not 100% sure.

Second Edit

Here is the website in question, should you wish to see the real example.

Many thanks.

  • We get these questions a lot! – closetnoc Nov 7 '16 at 5:38
  • @closetnoc I've seen a few questions similar to this, but in my scenario, there are/will be tons of directories with a single PHP file in them. The questions I saw were relating to many files in one directory. :) – DylRicho Nov 7 '16 at 5:57
  • 1
    I prefer to organize using directories for a few reasons. It is easier (for me anyway), it is better for users, and it is better for search performance. If need be, you can write a down-and-dirty script to help keep a large number of directories straight. Optionally, you use other tricks such as redirecting based upon patterns so directories do not actually have to exist. Or even easier, redirecting and passing the path to a script as a parameter. Cheers!! – closetnoc Nov 7 '16 at 6:09
  • 1
    NICE!! I would suggest making the CPU Grade header portion smaller for smaller screens (using an HP Mini) and so that it appears the page changes and allowing more of the content be shown above the fold. I am a big fan of smaller headers sections. Otherwise, perfection! Simple and effective. Well done! – closetnoc Nov 7 '16 at 6:16
  • 1
    I gotcha. The path is perfectly fine! I understand the 5k+ directories being a pain. Learn how to write a simple script that then creates links like you are creating paths now. Then use .htaccess (assuming Apache) to rewrite any request to /db/... as a parameter to a script that can read the content from a database. This will make your life a lot easier. Of course anything that size requires organization and attention to details. I did this with over 1 million pages before. – closetnoc Nov 7 '16 at 6:31
1

I would like to know if the current setup is going to give me trouble in the future.

You'll need to compare your setup with the filesystem the server uses and what you already have stored on the server. Some file systems may have a limit on the number of directories that can be made in one folder, but if you are only doing a few folders, this should not be an issue. A work-around to this can be to map your URL's to a script, and this can easily be done with apache's mod_rewrite module. For example, this code for mod_rewrite works:

RewriteRule ^(.*)$ /runscript.php?spec=$1

What this rule does is executes /runscript.php on your server passing the folder name as the parameter value for "spec". then you can use your script to determine the value and display the appropriate content all from one file. That way, you won't need to worry about creating separate folders or files, plus it's easier to maintain.

In your PHP file, you can have the following:

<?php
$spec=$_GET['spec'];

if ($spec=="486_machine"){
echo "This is the page about the 486 PC.";
}

if ($spec=="pentium"){
echo "This is the page about the pentium processor";
}

?>

If you try my script and you go to the URL http://example.com/pentium, then you'll see "This is the page about the pentium processor". Tweak the script well enough and you'll be able to share info about all processors.

| improve this answer | |
  • Hi Mike. Thank you for the example code. I have specs stored in independent databases. For example, one for AMD, one for Intel. And then each family (Athlon 64, FX, Pentium G, Core i7) has its own table. Each CPU model has its own entry in the table. How much more difficult would this make your example? With the current method, I also expect upward of 5,000+ directories (one for each model, plus the rest of the site), each with a single index.php file in them. That's why this is such a concern. – DylRicho Nov 7 '16 at 22:39
  • You can easily change my PHP code to include records from a database. Just ensure you have the correct server info as well as the username and password to the database and that the server is operational. You can look up database code on the internet to help you get started. – Mike -- No longer here Nov 8 '16 at 3:33
  • Is there any performance degrade from having so many mod_rewrite rules? I have one for each section of the website, but the one for the database in particular will be accessed the most (it's also the most complex, having five regular expressions). This site has been particularly helpful. – DylRicho Nov 8 '16 at 6:46
  • 1
    When you have many files being requested, the disk will need to be accessed at least once per file. With mod_rewrite rules targeting the same file, only one file needs to be accessed from disk and performance will then be a bit faster since the same file being accessed is already cached by the system. If your server requests numerous of index files and the cache isn't big enough to handle them all then the disk will be used which makes performance a bit slower. – Mike -- No longer here Nov 9 '16 at 17:48
  • 1
    Yes. The benefit to mod_rewrite pointing to one file is that the system needs to pay attention to only two major files: .htaccess, and the one target script file that processes your code. – Mike -- No longer here Nov 13 '16 at 18:22
1

As far as the full URL is concerned, you need to look at it in four parts.

[protocol://domain name][path][file name.extension][parameters]

The ranking of each part is from left to right in importance with an emphasis on the domain name and the path. File names and parameters count for little these days. Google seemed to go through phases finally deciding that the domain name and path offer the best semantic clues to what a web pages topic is about. The only semantic clue greater than the domain name and path is any link and link text to the page. After that, on-page factors become important.

You should not repeat anything. As well, where it applies, each path should read like a sentence. That may not be possible in your case. It is important to give as many semantic clues as you can.

Updating your example:

/core-i7/
    index.php
    /i7-6700/
        index.php
    /i7-6700k/
        index.php
    /i7-6700t/
        index.php

Adding more semantic clues

/processor/core-i7/
        index.php
        /i7-6700/
            index.php
        /i7-6700k/
            index.php
        /i7-6700t/
            index.php

I would add that index.php does not add any semantic value. You can rename the file, of course, however, I am a big fan of URLs such as example.com/processor/core-i7/ where the index.php is not linked to and does not show.

For clues as to how to organize this better, read: Well structured URLs vs. URLs optimized for SEO

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.