Have been going round in circles for a few hours, would really appreciate a little help.
I am trying to rewrite URLs that include a query string (preceded by company.php).
I found a few ways to get the rewrite itself to work, but it always shows a 404 :(
For example I need to rewrite (using example value):
http://test.domain.com/company.php?companynumber=05614768
to:
http://test.domain.com/company/05614768/
Here is a couple I have managed to get to do the rewrite but are 404ing:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/company\.php$
RewriteCond %{QUERY_STRING} ^companynumber=([0-9]*)$
RewriteRule ^(.*)$ http://test.domain.com/company/%1/? [R,L]
and
RewriteEngine On
RewriteCond %{QUERY_STRING} ^companynumber=([0-9]*)$
RewriteRule ^company\.php$ http://test.domain.com/company/%1/? [R,L]
I am guessing I need to figure out how do an internal redirect as well as the external redirect? But I am really struggling...
Centos 6.6 / Apache 2.4.12