I am trying to use .htaccess file for my REST service but I found that the url are not actually redirected. The web server show
I wanted to use url such as
/api/v1/test
instead of
/api/v1/rest.php?request=test
I have already check mod_rewrite is acutally working.
My .htaccess file is as below
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule api/v1/(.*)$ api/v1/rest.php?request=$1 [QSA,NC,L]
I have already look at PHP redirecting problem and Sitemap redirecting
you can try this rule instead because it works with me :
RewriteRule api/v1/([A-Za-z0-9-]+)/?$ api/v1/rest.php?request=$1
try putting .htaccess file in htdocs directory and if the directory api location is
C:\xampp\htdcos\xampp\www\api
then put the full path in the rule
this site generates mod_rewrite
for you:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api/v1/([^/]*)$ /api/v1/rest.php?request=$1 [L]