Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I propose you create a file under graph (or literally anywhere, it's up to you), for example <code>graph/index.php</code> that will handle the graph rewrite requests. You would then move <code>show.php</code> (and other files you want to redirect) to a different folder appropriate for processing stuff, for example under <code>graph/lib</code>. </p> <p>Now imagine that everything following <a href="http://labs.helloboy.com/graph/" rel="nofollow">http://labs.helloboy.com/graph/</a> is "non-existant", you just handle the requests based on the paths (like <em><a href="http://labs.helloboy.com/graph/load/show" rel="nofollow">http://labs.helloboy.com/graph/load/show</a></em>). </p> <p>The fictive filestructure is something like this:</p> <pre><code>root (in your case it would prolly be www/labs) -- .htaccess -- graph -- index.php (handles rewrites, can be anywhere you want but it must be reflected in the .htacces file) -- lib (location to store the existing files, can be anywhere you want) -- show.php -- delete.php -- ..etc </code></pre> <p>First of all let's add the rules in .htaccess that will handle the requests and also do the .php redirection:</p> <h2>.htaccess</h2> <pre><code>RewriteEngine on # Make sure index.php requests are NOT rewritten, otherwise we'll end up in an endless loop. RewriteCond %{HTTP_HOST} ^labs\.helloboy\.com$ RewriteCond %{REQUEST_URI} ^graph/index\.php$ RewriteRule .* - [L,NC,QSA] # Redirect all .php files and remove the extension RewriteCond %{HTTP_HOST} ^labs\.helloboy\.com$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(graph/.+)\.php$ $1 [R,NC,QSA] # Make sure that we won't match existing files or directories, otherwise the lib files will fail. Get the path after "graph/" and add it as a path argument to "graph/index.php". RewriteCond %{HTTP_HOST} ^labs\.helloboy\.com$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^graph/(.*) graph/index.php?path=$1 [L,NC,QSA] </code></pre> <p>We would then need to process the path argument sent to our handler so we can do something useful with it. Note the DEBUG comments, the calls beneath them creates output which I will show later.</p> <h2>graph/index.php</h2> <pre><code>&lt;?php // NOTE: Consider returning a 404 status code with the header and possibly a redirect if you can't process the paths sanely. //====== // DEBUG //====== ?&gt;&lt;pre&gt;&lt;?php var_export( $_GET ) ?&gt;&lt;/pre&gt;&lt;?php $path = isset( $_GET['path'] ) ? $_GET['path'] : ''; if ( $path ) { // Split the path into parts. For example load/show/ becomes an array with two elements: ['load', 'show'] $paths = array_filter( explode( '/', $path ) ); //====== // DEBUG //====== ?&gt;&lt;pre&gt;&lt;?php var_export( $paths ) ?&gt;&lt;/pre&gt;&lt;?php $len = count( $paths ); if ( $paths ) { // If we have any path we attempt to process it if ( $paths[0] === 'load' ) { // Do something if load if ( $len &gt; 1 ) { $action = $paths[1]; switch ( $action ) { case 'show': $file = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . "$action.php"; //====== // DEBUG //====== var_dump( $file ) ; if ( file_exists( $file ) ) require_once $file; break; } } } } } ?&gt; </code></pre> <p>For the path <a href="http://labs.helloboy.com/graph/load/show/" rel="nofollow">http://labs.helloboy.com/graph/load/show/</a> the script would output the following: </p> <pre><code>// This is the contents of the supervariabel $_GET array ( 'path' =&gt; 'load/show/', ) // This is the path parts after splitting and filtering of the path argument array ( 0 =&gt; 'load', 1 =&gt; 'show', ) // Here we illustrate that we can include/process any file we wish based on the path contents string '/your/server/path/graph/lib/show.php' (length=xx) </code></pre> <p>Please let me know if you need further simplification to understand this suggestive solution.</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. VO
      singulars
      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