I am trying to set up IIS7 so the a URL with the pattern:
www.test.com/docs/ADocument.pdf
will get redirected to the URL
www.test.com/1.0/docs/ADocument.pdf
I am having trouble with the regular expression. The pattern should work with any page at the end of the url.
Rewrite this...
^(docs/.*)$
to this...
1.0/{R:1}
Related
Apache RedirectMatch, which regex to ignore in some cases?
Hi everyone,
I have a RedirectMatch that allows me to redirect domain-one.com to domain-two.com based on the language parameter in the URL.
For example :
https://domain-one.com/en/*
-->
https://domain-two.com/en/*
I use this Apache condition:
<If "%{HTTP_HOST} == 'domain-one.com'">
RedirectMatch 301 ^/en/(.*)$ https://**domain-two.com**/en/$1
</If>
I would like to know what Regex I should put to ignore this redirect if a very specific keyword is in the base url, for example :
https://domaine-one.com/en/**connect**/*
I tried this expression and it works, but only if the URL ends with "connect", it does not work if the URL is for example "/en/connect/page1" :
RedirectMatch 301 ^/(?!.*connect$)(.*)$ https://domain-two.com/$1
I don't want to redirect if the word "connect" is present in the URL.
I'm not an expert in Regex I admit...
Does anyone have an idea?
Thanks a lot in advance
I'm stuck at regex pattern.
Currently I'm using regex:
https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,}
but it takes www.google.co.in as a valid url but I want http:// or https:// as a required part of url.
Is there any way I can achieve that?
I have IIS and want to configure URL rewriting.
How I can to rewrite any type of URL like:
http://anydomain.com/subfolder/page.html
to
http://anydomain.com/mysubfolder/subfolder/page.html
So only what I need is to add just one subfolder name into URL after host name.
Regex for split url
^(https?:\/\/[^\/]*\/)(.*)$
and How-To iis url rewrite. Your pattern must look like that
{R:1}mysubfolder/{R:2}
if url is like this
http://samplexxxx.com/some keywords/ it has to redirect to
http://samplexxxx.com/ap/search.php?searchterm=$1
for that i had written like this
RedirectMatch 301 ^/([^/]*)/ http://samplexxxx .com/ap/search.php?searchterm=$1
it was working fine
but here matching keywords should not ap i.e
http://samplexxxx.com/ap/
so here redirection should done other than ap keywords then how do i need to change the regular expression matching pattern.
You can use negative lookahead in your regex:
RedirectMatch 301 ^/((?!ap/)[^/]+)/ http://samplexxxx .com/ap/search.php?searchterm=$1
I'm trying to do a URL rewrite when a user accesses a certain URL of my site:
Accessed URL: https://client1.domain.com
Rewritten URL: https://new-client1.otherdomain.com
My site has many URLs that point to it, so the simple HTTP redirect module will not be a valid solution for this. What would the Regex be and what would I want to fill in for each section in a rewrite rule?
Thanks
Try this:
s/client1.domain/new-client1.otherdomain/g
You can use this regex pattern to search for client1.domain in order to replace it:
(?<=//)([^.]+)\.domain
Replace it with a backreference to client1 and the new domain like so:
$1\.otherdomain