Change the url as the query var in htaccess wordpress

I have a url like http://exmple.com/company/?n=Brunswick%20&%20Sons.

First, i have read this post. https://serverfault.com/questions/214512/redirect-change-urls-or-redirect-http-to-https-in-apache-everything-you-ever

Read More

But i cant understand rewrite rule easily. I want the query as like http://exmple.com/company/Brunswick%20&%20Sons.

Can anyone help to understand this thing do this work 100%.

Related posts

1 comment

  1. Try the following code in root/.htaccess:

      RewriteEngine On
    
    #1)Redirect from http://example.com/company/?q=foo
    #to http://example.com/foo
    RewriteCond %{THE_REQUEST} /company/?n=(.+)s [NC]
    RewriteRule ^ /%1? [B,NC,L,R]
    #first round of rewriting ends here
    
    
     #2) in this round , mod_rewrite will
     #internally map http://example.com/foo to
    #http://example.com/company/?n=foo.
    #the following 2 conditions check if the /foo is an existent directory or file, skip the rewrite
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^([^/]+)/?$ /company/?n=$1 [B,NC,L]    
    

Comments are closed.