I am beginner in Apache rewrite URL.
I have a problem to rewrite URL.
I would like to rewrite http://www.test.com/abc/index.php?val=123 to http://www.test.com/abc/123/index.php
Note: abc is folder
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/([0-9]+)/index.php $1/index.php?val=$2 [QSA,L]
Your regular expression in the RewriteRule made no sense. In addition you cannot reference parts of the query string in a RewriteRule, so you have to additionally use a RewriteCond to capture the query arguments.
Try this one:
It is always a good idea to have apache itself help you with debugging expressions: use the logging feature: read the documentation for the two commands
RewriteLogandRewriteLogLevel. They dump each step taken and allow to understand what is actually happening inside the algorithm.All information required is offered in the fine documentation. It really is worth working through…