I have trouble rewriting virtual directories as variables.. can someone help please?
The URL is: https://www.example.com/content/index.php?var=1-dKein4i59xcNjfks
I want it to look like: https://www.example.com/content/featured/1-dKein4i59xcNjfks
where "content" is a real directory and "featured" and "1-dKein4i59xcNjfks" are virtual my current .htaccess code is incorrect as:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ content/index\.php\?var=([^\&\ ]+)
RewriteRule ^content\/?index\.php$ /var/%1? [L,R=301]
Can someone assist please? thanks
With your shown samples please try following. Make sure to clean your browser cache before testing.
RewriteEngine ON
##Using THE_REQUEST for catching references and using them later on.
RewriteCond %{THE_REQUEST} \s/(content)/index\.php\?var=(.*?)\s [NC]
RewriteRule ^ /%1/featured/%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(content)/featured/(.*?)/?$ $1/index.php?var=$2 [QSA,NC,L]