大网数据广告活动
网站运营与故障问答

Is there any real tangible benefit from replacing many one-file directories with many files in one directory?

· 52CE 我爱测

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 Skylak…

问题原文

原帖链接 · DylRicho · CC BY-SA 3.0

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.

已采纳解答

原帖链接 · Mike -- No longer here · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2016-11-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。