Search code examples
phpmod-rewritepermalinks

php mod_rewrite Permalinks


I am looking for a way to access to:

 http://myurl.com/?file=random_token 

with

 http://myurl.com/random_token/

I already read about mod_rewrite in the .htaccess but I don't know how to setup the pattern.

I tried this:

Options +FollowSymLinks
RewriteEngine on
RewriteRule /(.*)/$ /index.php?file=$1

It would be nice if you can help me.


Solution

  •     RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^([^/]*)/$ /?file=$1 [L]