Rewrite URL parameters with htaccess

See here for the original answer.

Here's a copy of my answer to a similar question. Hopefully it'll help you:

This page appears to have a solution to what you are trying to do:

<?
    $Params = explode( '/', $PATH_INFO );

    while( list( $Index, $Value ) = each( $Params )) {
        echo "Params[ $Index ] = $Value<BR>\n";
    }
?>

Hit this URL:

http://whatever.site.com/ThisIsAProgram/these/directories/are/not/real

You should get:

Params[ 0 ] =

Params[ 1 ] = these

Params[ 2 ] = directories

Params[ 3 ] = are

Params[ 4 ] = not

Params[ 5 ] = real

And to display the PHP file as just the file name, try this:

Options +MultiViews
RewriteEngine On

RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]

If you are wanting a more complete example, this answer covers it a lot more in depth than I could. This will definitely help you cover all your bases and understand the issue if my other linked article doesn't make it clear enough.


Tags

  1. php (Private)
  2. htaccess (Private)
  3. rewrite (Private)
  4. stack-overflow (Private)
  5. answer (Private)