0

Hello All,
I need to rewrite http://mysite.com/user/profile/following?profile_name=MYNAME to http://mysite.com/user/profile/MYNAME/following

I have written rule like this:

RewriteRule user/profile/(.*)/(.*) /user/profile/$2?profile_name=$1 [L,R=301]  

when i put url like http://mysite.com/user/profile/MYNAME/following in the browser it always redirect me to http://mysite.com/user/profile/following?profile_name=MYNAME

What did i miss?

Thanks in Advance

Awlad Liton
  • 9,366
  • 2
  • 27
  • 53

1 Answers1

0

You can use this code:

# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+user/profile/([^?]+)\?profile_name=([^\s&]+) [NC]
RewriteRule ^ /user/profile/%1/%2? [R=301,L]

# internal forward from pretty URL to actual one
RewriteRule ^user/profile/([^/]+)/([^/]*)/?$ /user/profile/$2?profile_name=$1 [L,NC,QSA]  
anubhava
  • 761,203
  • 64
  • 569
  • 643