Matt
Matt

Reputation: 345

Rewrite a URL Apache

I’m attempting to rewrite a link on my Apache config file so that it looks like an internal link, but is actually external.

The link on my site will look like this, and have multiple querystrings.

http://www.mysite.com/myscript.asp?somevar=1&othervar=2

But when clicked will be rewritten as this:

http://www.othersite.com/script.asp?somevar=1&othervar=2

Here is where I am so far (not working):

RewriteRule ^myscript.asp?(.*)$ http://www.othersite.com/script.asp?(.*) [L]

Can anybody get this rule working? Thanks!

Upvotes: 0

Views: 50

Answers (1)

undone
undone

Reputation: 7888

I hope this would be helpful:

RewriteRule ^myscript\.asp\?(.*)$ http://www.othersite.com/script.asp?$1 [L]

Note: question mark(?) and dot(.) have special meaning in reqular expresion, so if you want to use them as meaningless character put \ before them!

Upvotes: 1

Related Questions