How to redirect for a particular word in URL (htaccess)?

In the project there is a folder api. Inside this folder are two files index.php and mobile.php.
Need to do a redirect. If the user knocks in the /api/get-courses it is necessary to redirect to index.php. But if /api/mobile.php/get-courses on mobile.php
March 23rd 20 at 19:08
1 answer
March 23rd 20 at 19:10
RewriteRule ^api/get\-courses$ /api/index.php? [L,R=301]
RewriteRule ^api/mobile\.php/get\-courses$ /api/mobile.php? [L,R=301]

And get a sense of the task as a minimum of 3 errors in TK, so I had to figure out the correct URLs though the show had become
Himself .htaccess is in the folder API.
.htaccess file(the End result):
RewriteEngine On
RewriteBase /api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} mobile\.php
RewriteRule ^ mobile.php [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

Request DOMEN/api/mobile.php/get-course goes into mobile.php
Request DOMEN/api/get-course goes into index.php - reed.Anderson commented on March 23rd 20 at 19:13
DOMEN/api/mobile.php/get-course - maybe you mean DOMEN/api/mobile.php?get-course - Kaitlin5 commented on March 23rd 20 at 19:16

Find more questions by tags Processing URLhtaccess