Search code examples
php.htaccessurlurl-rewriting

.htaccess problems, impossible for me to remove .php


I want your help. I have this url: wwww.myurl.com/?verfy=CDPOR888 OR wwww.myurl.com/index.php?verfy=CDPOR888

I would like to be like this: wwww.myurl.com/CDPOR888

Please help, how can i do it with .htaccess?

I tried this code in .htaccess but not working:

RewriteRule ^([^/]*)\.php$ /?perms_verify=$1 [QSA,L,NC]

but the problem is .php, when i remove it i get an error.

NOTE: .htaccess with case insensitive


Solution

  • You may just use this rule:

    RewriteEngine On
    
    # request is not for a file
    RewriteCond %{REQUEST_FILENAME} !-f
    # request is not for a directory
    RewriteCond %{REQUEST_FILENAME} !-d
    # rewrite to destination path
    RewriteRule ^([\w-]+)/?$ ?verfy=$1 [QSA,L]