I am trying to rewrite a url. I want to enter this url in the browser:
localhost/subDir/page-name/value1/value2
and then read value1 en value 2 into a querystring, so like this:
localhost/subDir/page-name/?firstArg=value1&secondArg=value2
This is for a wordpress website. The wordpress is installed in a subdirectory, called “subDir”. The wordpress page is called
page-name” and going to localhost/subDir/page-name works. The standard permalinks are working, so mod_rewrite is enabled. This is my .htacces file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subDir/
RewriteRule page-name/([^/]+)/([^/]+)/? page-name/?firstArg=$1&secondArg=$2 [QSA]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subDir/index.php [L,QSA]
</IfModule>
# END WordPress
mod_rewrite does not consider the query string as part of the URI for matching
and rewriting, It should be treated separately.
[R] indicates to direct to URL constructed by the RewriteRule directive
You can replace your current code by this one