1

htaccess with php, I need to rewrite the below url

 freelancers.php?new=user

as

 register.php?new=freelancer

can any one help me out on this.

Amit Verma
  • 40,709
  • 21
  • 93
  • 115
Sidda
  • 109
  • 1
  • 5
  • 1
    possible duplicate of [URL rewriting with PHP](http://stackoverflow.com/questions/16388959/url-rewriting-with-php) – Nathan Tuggy May 24 '15 at 02:02
  • this is not about rewriting with friendly url but I wanted to rewrite the complete path like from freelancer.php page to register.php. – Sidda May 24 '15 at 02:18
  • Yes. That would be included, since the dupe target I linked is extremely broad: the general pattern is basically the same one. "My URL sections aren't exactly the same as in the example" is not much of a distinction to make. – Nathan Tuggy May 24 '15 at 02:20
  • you are using same page with different pattern for query string but I need different pages with different query strings – Sidda May 24 '15 at 02:42
  • @NathanTuggy The linked question does not give any information about the query string. I'll see if I can find a better dupe target. – Sumurai8 May 24 '15 at 09:19
  • 1
    Maybe: http://stackoverflow.com/questions/1497184/replacing-a-querystring-parameter-value-using-mod-rewrite or http://stackoverflow.com/questions/5606916/url-rewrite-query-string – Sumurai8 May 24 '15 at 09:45

1 Answers1

0

You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} /register.php\?new=freelancer\s [NC]
RewriteRule ^ freelancers.php?new=user [R=302,L,NE]

RewriteCond %{QUERY_STRING} ^new=user$ [NC]
RewriteRule ^freelancers\.php$ register.php?new=freelancer [L,NC]
anubhava
  • 761,203
  • 64
  • 569
  • 643