Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #15911

Re: Fast PHP way to find a file given the leftmost characters of the file name

From Arno Welzel <usenet@arnowelzel.de>
Newsgroups comp.lang.php
Subject Re: Fast PHP way to find a file given the leftmost characters of the file name
Date 2015-12-05 19:37 +0100
Message-ID <56632ECD.8050106@arnowelzel.de> (permalink)
References <n3v7c9$ko9$1@dont-email.me>

Show all headers | View raw


James Harris schrieb am 2015-12-05 um 18:39:

[...]
> The URL could include the full name (without an extension) or just a 
> short prefix. For example, if the file names were
> 
>    1001-this-is-a-file.ext1
>    1002-this-is-too.ext2
>    1003-so-is-this.ext1
> 
> the first of those files could be accessed by either of these URLs:
> 
>    http://site.com/dir/1001-this-is-a-file
>    http://site.com/dir/1001
> 
> As you can see, the second name is the short form of the first.
> 
> The requests would be directed to a PHP script by URL rewriting. Either 
> of the URLs could be used to find the same file.

Use a database where you store the file names (for example using a kind
of maintance script which regularly scans the directory and updates a
database table with the current list of files). Otherwise you would have
to scan the directory with every request to get the existing file names
as a list and find out, which one matches - and this would not be very
efficient.

[...]
> I guess something like this approach to URL shortening is fairly common 
> for SEO reasons. Maybe there is a standard solution...?

Nope.

WordPress for example does this "auto completion" as well - but the URLs
in WordPress are already only in the database and don't even exist as
files. Many other CMSes handle this in a similar way.

So for example:

When you access

<http://arnowelzel.de/wp/en/tools/spoke>

you will get redirected to the real URL

<http://arnowelzel.de/wp/en/tools/spoke-length-calculator>

But this is not done to provide and kind of SEO - it's just for
convenience. The opposite is true: Using descriptive URLs is better
since the URLs are then also part of the search.

Also see:

<https://moz.com/blog/15-seo-best-practices-for-structuring-urls>

What really hits search engine results is changing old URLs without
forwarding to the new ones.

<http://www.w3.org/Provider/Style/URI.html> is still true.


-- 
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
http://fahrradzukunft.de

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Fast PHP way to find a file given the leftmost characters of the file name James Harris <james.harris.1@gmail.com> - 2015-12-05 17:39 +0000
  Re: Fast PHP way to find a file given the leftmost characters of the file name Arno Welzel <usenet@arnowelzel.de> - 2015-12-05 19:37 +0100
  Re: Fast PHP way to find a file given the leftmost characters of the file name Markus Heinz <markus.heinz@uni-dortmund.de> - 2015-12-05 19:45 +0100
    Re: Fast PHP way to find a file given the leftmost characters of the file name Matthew Carter <m@ahungry.com> - 2015-12-05 14:45 -0500
      Re: Fast PHP way to find a file given the leftmost characters of the file name Jerry Stuckle <jstucklex@attglobal.net> - 2015-12-05 15:53 -0500
      Re: Fast PHP way to find a file given the leftmost characters of the file name James Harris <james.harris.1@gmail.com> - 2015-12-06 00:50 +0000
        Re: Fast PHP way to find a file given the leftmost characters of the file name Matthew Carter <m@ahungry.com> - 2015-12-07 00:17 -0500
          Re: Fast PHP way to find a file given the leftmost characters of the file name James Harris <james.harris.1@gmail.com> - 2015-12-08 11:45 +0000

csiph-web