Inhalte aufrufen

Profilbild

URL Rewrite to other domain


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
Keine Antworten zum Thema vorhanden

#1 TripleNico

TripleNico

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 124 Beiträge

Geschrieben: 15 June 2020 - 11:16

Hi,
 
I try to setup the URL Rewrite module to rewrite a request to another URL, however it doens't seem to work. This is what i got:

/media/(.*) /https://sub.other.com/$1 [R=301, NC]

So this hase to redirect everything after /media to another domain (not SmartStore but other website in same IIS) with then the end of the URL passed. I can do this in the web.config but i prefer to keep it all in SmartStore backend keeping updates in mind.
 
I checked https://httpd.apache...ml#movehomedirs and it seems the way i wrote it is correct?
 
Edit:
Fixed it by setting url rewrite rules globally for IIS so before SmartStore get's loaded the redirect is already applied. Also i have taken into account that SmartStore also uses the /media structure.
 
For those who whan't to know how i did it:

<rule name="x.domain.com/Media to share.domain.com" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
    <match url="^media/(.*)" />
    <action type="Redirect" url="https://share.domain.com/{R:1}" appendQueryString="false" redirectType="Permanent" />
    <conditions logicalGrouping="MatchAny">
        <add input="{REQUEST_URI}" pattern="^/media/audio/(.*)" />
        <add input="{REQUEST_URI}" pattern="^/media/mail_resources/(.*)" />
        <add input="{REQUEST_URI}" pattern="^/media/pdf/(.*)" />
        <add input="{REQUEST_URI}" pattern="^/media/software/(.*)" />
        <add input="{REQUEST_URI}" pattern="^/media/video/(.*)" />
    </conditions>
</rule>

The reason that i created this rule is because our old website had a /media directory with lots of files in them that got shared over time via email and stuff. All the files where copied over to a new webserver so the previous links still has to work, else alot of stuff whould go wrong.