-1

The below link was markes as a solution but it is not this is not a domain issue this is a url issue as in the part that comes after the domain name. Apache RewriteRule to remove port on any domain name

example structure

/grid is a folder
/hypergrid.php/ is a file
/:80 is god knows what and needs to be gone
/foreignagent is variable
/ff11bc47-2deb-a55a-9531-08706d736121 is the variable value

I have a program that sends data to a website. bellow is a example of a request from this program.

i do not know why it is injecting a port in the middle of the url but i do not want to rewrite the software. how do i remove :80 from the url using htaccess?

/grid/hypergrid.php/:80/foreignagent/ff11bc47-2deb-a55a-9531-08706d736121/

this url should look like

/grid/hypergrid.php/foreignagent//

this part of the url is not static `

foreignagent/ff11bc47-2deb-a55a-9531-08706d736121/`
Community
  • 1
  • 1

1 Answers1

0

Something like this should work:

RewriteEngine On
RewriteRule ^:80/(.*)$ /$1 [R=301,L]

This assumes the client will follow redirects. If not you'll likely need something like ProxyPass, which won't work in .htaccess but needs to be in the Apache config files.

Will Hogan
  • 909
  • 4
  • 9
  • [Sat Oct 17 12:39:26.131358 2015] [core:error] [pid 3288:tid 2232] (20024)The given path is misformatted or contained invalid characters: [client 64.31.16.122:48072] AH00127: Cannot map POST /grid/hypergrid.php/:80/foreignagent/ff11bc47-2deb-a55a-9531-e8706d736121/ HTTP/1.1 to file – Kristopher Therrien Oct 17 '15 at 19:40
  • Ahh, a little different perspective after the edits. Perhaps: `RewriteRule ^(.*)/:80/(.*)$ /$1/$2 [R=301,L]` – Will Hogan Oct 17 '15 at 19:54
  • will hogan your answer is the closest except for making it a redirect i can not redirect. can this rule stip from the url? – Kristopher Therrien Oct 17 '15 at 20:30
  • You can remove the 301, `RewriteRule ^(.*)/:80/(.*)$ /$1/$2 [L]`. This doesn't strip it, but returns the response from the functioning URL. To actually change the request URL (stripping the :80) sent to Apache, you need to either proxy or use a redirect. – Will Hogan Oct 17 '15 at 20:38