I am trying to achieve that a url like
example.com/path1 to example.com/index.php?p1=path1
example.com/path1/path2 to example.com/index.php?p1=path1&p2=path2
In my .htaccess I have:
RewriteEngine On
RewriteRule ^(.*)/(.*)$ /index.php?c=$1&g=$2 [NC,L]
RewriteRule ^([a-zA-Z0-9-_]+)$ /index.php?g=$1 [NC,L]
It works well for the case where we have the example.com/path1/path2 but for the the case example.com/path1 only works if there is no dot in the url. For example, I want to example.com/mydomain.com working to example.com/index.php?g=domain.com but I am not able to make it working.
Could you help me with this please?
([a-zA-Z0-9-_]+)you are explicitly only handling the case of alpha-numeric plus underscores. That would exclude your sample case.