.htaccess problems, impossible for me to remove .php

Viewed 59

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

3 Answers

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]

Please replace this rule!

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
# Use this rule
RewriteRule ^([^\.]+)$ $1.php [NC,L]

Update your .htaccess file as

DirectoryIndex index.php

# remove the next 3 lines if you see a 500 server error


FileETag none
ServerSignature Off

Options All -Indexes

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([0-9a-zA-Z_-]{1,16})$ index.php?verify=$1 [L]
</IfModule>

On wwww.myurl.com/index.php page , write the logic to catch verify value using GET method and do your further operations

Related