I'm working a flatfile blog style script project, the text file names are layed out like so:
05--im-a-title-and-may-c0ntain-lett3r5-and-numb3rs--14-12-2014
I use explode()
--
to split into 3 parts for index listing
$id
$title
$date
link to single page being $title
The single page code at the moment is:
$search = $dir . "*" . clean($_GET['title']) . "*" . '.txt';
$files = glob($search);
$getfile = $files[0];
echo file_get_contents($getfile);
As you see I am using globe()
and it's wildcards to match the $_GET
to file name to grab the file content and to remove/hide id and date parts from url which is working fine but once the files start piling up it will also start to get very server intensive having to search many files so wanting to fix this problem before it even starts so looking for a much better way to remove/hide parts from $_GET
whist still finding the correct file.
Update:
The purpose of this is to make single page url cleaner domain.com/i-am-a-title
rather than domain.com/05--im-a-title--14-12-2014
Update 2:
RewriteRule ^([a-zA-Z0-9_-]+)$ single.php?title=$1 [L]