Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The simplest way would probably be to move all the aricle files outside the web root, and then use PHP to fetch them if the client is allowed to see it.</p> <p>For example:</p> <pre><code>&lt;?php if (isset($_GET['id'])) { $articleDir = "/var/articles/"; // Assuming a "?id=1" query string is used to pass a numberic ID of // an article. (Like: example.com/showArticle.php?id=1) $articleID = (int)$_GET['id']; $articleFile = "article_{$articleID}.html"; // Look through your SQL database to see if the article is restricted. // I'll leave the codeing to that up to you though. if (!$isRestricted || $isLoggedIn) { $path = $articleDir . $articleFile; if (file_exists($path)) { include $path; } else { echo "The requested article does not exist."; } } else { echo "You have to be logged in to see this article."; } } else { echo "No article ID was passed. Did you perhaps follow a bad link?"; } ?&gt; </code></pre> <p>Note that if you want to keep the old links alive, you can use Apache's mod_rewrite to rewrite incoming requests and route them to your PHP file.</p> <p><strong>Edit</strong></p> <p>This may help if you are new to mod_rewrite and/or regular expressions:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteRule ^article_(\d+)\.html$ fetchArticle.php?id=$1 [L] &lt;/IfModule&gt; </code></pre> <p>Routs any link such as <code>example.com/article_123.html</code> to <code>example.com/fetchArticle.php?id=123</code> without the client noticing it.</p> <p>Similar to what Dan Grossman did, but this one fetches only numbers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload