I recently write url in my website via htaccess from query string to virtual folders and it's working nicely. Because of SEO issues I need to redirect old pages to new virtual folder addresses.I am having trouble with redirecting pattern and I am desperated :(
I need to redirect url like ?page=artreader&id=56 to fa/56
I am using this code in htaccess but its not working fine:
RedirectMatch 301 ^(.+)page=artreader&id=(.+)$ http://www.mywebsite.com/fa/$2
I appreciate it if anyone can help me.
You can use this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteBase /
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} \?page=artreader&id=([^\s&]+) [NC]
RewriteRule ^ fa/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteRule ^fa/([^/.]+)/?$ ?page=artreader&id=$1 [L,QSA,NC]