There is a script that takes two get parameters as input:

 mysite.com/do.php?from=file&act=replace 

Is it possible to make it so that this script can be accessed at

 mysite.com/file/replace 

?

  • one
    possibly. mod_rewrite , RewriteRule your keywords to search for and solve this problem, if we are talking about the server apache - teran

1 answer 1

I'm not sure that you need exactly what you want, but in this case Apache will have the following config in the .htaccess file:

 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^/(.*)/(.*)$ do.php?from=$1&act=$2 [L,QSA] 

But this is not the right solution, but it will work, by analogy you can write a rule for Nginx:

 location / { if (!-e $request_filename){ rewrite ^/(.*)/(.*)$ /do.php?from=$1&act=$2 break; } } 

However, I repeat that you need to think 10 more times before applying this rule.