Reputation: 546
Please help me with this one, which should be easy but I've never managed to properly learn Apache mod_rewrite's syntax...
I have a REST webservice implemented in PHP and I need to rewrite the following URL:
[1] http://www.myserver.com/service/ca;x={valx},y={valy},z={valz}
into
[2] http://www.myserver.com/service/ca.php?x={valx}&y={valy}&z={valz}
How to accomplish this?
I'm using Apache2 on Ubuntu, this is the configuration:
Alias "/service" "/opt/htdocs/service"
<Directory "/opt/htdocs/service">
AllowOverride All
Options -Indexes FollowSymLinks
</Directory>
and the content of my /opt/htdocs/service
directory:
$>ls -1 /opt/htdocs/service
ca.php
Mod_rewrite is enabled:
$>a2enmod rewrite
Module rewrite already enabled
Thanks in advance!
Upvotes: 1
Views: 1728
Reputation: 143896
Try putting this in your server/vhost config or the htaccess file in your document root:
RewriteEngine On
RewriteRule ^/?service/ca;(.*)$ /service/ca.php?$1 [L]
RewriteCond %{QUERY_STRING} ^(.*),(.*)$
RewriteRule ^/?serivce/ca\.php$ /service/ca.php?%1&%2 [L]
Upvotes: 1