"Friendly URLs" - .htaccess

0

I need help with friendly URLs using the Apache .htaccess file. I explored several publications and none of them has worked for me, because I need two parameters .

For example: https://api.mysite.com/api/url/create

/ api / is a directory

It will be treated as: https://api.mysite.com/api/url.php?act={create, delete, etc}

PS : Parameter 1 would be url or whatever, which opens the file parametro1.php, the second would be create or anyone that specifies the GET parameter to the file.

    
asked by Derek Nichols 30.07.2017 в 22:35
source

1 answer

0

You should do something like this:

RewriteRule ^api/url/(.*) api/url.php?act=$1

What this line does is send a rule, or write a 'RewriteRule' rule where you can find the address api/url.php?act=$1  where act= is the variable you're going to get, and $1 is the value of the variable (you have to start with $ because that tells .htacccess that the value will be a variable), then all this will replace it with the address you want, in this case api/url/(.*) , where (.*) will be the value of the variable in the new one url, in this case you can be any value, number or letter.

    
answered by 30.07.2017 в 22:42