Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would approach this a little differently. If you are not very familiar with Apache, then my recommendation would be that you take as much responsibility away from Apache as you can and set up a "dispatcher" script that decides which PHP file is executed by inspecting the requested URI.</p> <p>The idea is pretty simple: "redirect" every request to <strong>one</strong> PHP file, and then use that file to determine which file you actually want to execute. </p> <p>E.g.</p> <p><a href="http://domain.com/" rel="nofollow">http://domain.com/</a> => index.php?request=</p> <p><a href="http://domain.com/moo/" rel="nofollow">http://domain.com/moo/</a> => index.php?request=moo/</p> <p><a href="http://domain.com/moo/1/2/3/4/" rel="nofollow">http://domain.com/moo/1/2/3/4/</a> => index.php?request=moo/1/2/3/4/</p> <p>Et cetera</p> <p>Example:</p> <p>(This is assuming you have .htaccess and index.php files in your web root)</p> <p><strong>.htaccess:</strong></p> <pre><code># "Hi Apache, we're going to be rewriting requests now!" # (You can do all this in Apache configuration files too, of course) RewriteEngine On RewriteBase / # Ignore *.gif, *.jpg. *.png, *.js, and *.css requests, so those files # will continue to be served as per usual RewriteRule \.(gif|jpg|png|js|css)$ - [L] # For the rest, convert the URI into $_GET[ 'request' ] RewriteRule ^(.*)$ index.php?request=$1 [QSA] [L] </code></pre> <p><strong>index.php:</strong></p> <pre><code>&lt;?php print "&lt;pre&gt;Request: " . $_GET[ 'request' ] . "\n"; // Dispatcher should be smarter than this -- otherwise you // will have serious security concerns $filename = $_GET[ 'request' ] . '.php'; if( file_exists( $filename ) === TRUE ) require( $filename ); else print "Not found: $filename"; </code></pre>
 

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