I'm developing an api. Basically it requests a page according to the request.
Example: http://localhost/mod/<name>/<version>
the problem is being / version. I did htaccess this way:
Options +FollowSymLinks
RewriteEngine on
RewriteRule /mod/(.*) /mod.php?name=$1
RewriteRule /mod/(.*)/(.*) /mod.php?name=$1&version=$2
RewriteRule /modpack/(.*) /modpack.php?slug=$1
RewriteRule /modpack/(.*)/(.*) /modpack.php?slug=$1&build=$2
However if I require eg /mod/test/1.0 or no $_GET['version']
it says that the index version is null.
<?php
echo "It works! name=" . $_GET['name'] . ',version=' .$_GET['version'];
?>
I used this line: RewriteRule /mod/(.*)/(.*) /mod.php?name=$1&version=$2
But it puts the version together with the name:
Notice: Undefined index: version in C: \ xampp \ htdocs \ mod.php on line 2
It works! name = test / 1.0, version =
The same thing happens in /modpack/<slug>/<build>
RewriteRule /modpack/(.*)/(.*) /modpack.php?slug=$1&build=$2