routing /content image references to /wwwroot

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Hello-

I'm upgrading a site to version 4.0. That site uses a 3rd party plugin to display content in a section of the website. Those content articles contain very many references to images at their location in the /content directory.
In addition, within many product descriptions, blog posts, and on external/remote websites, we have similar image references.
I understand that 4.0 has a different folder structure and that the images folder is now within the /wwwroot directory.

Rather than need to track down and correct all those image references, I'm wondering if it would be possible to just create some kind of rewrite rule in my web.config for image resource requests made from the /content directory? Or does that only work for page URL's??

The only other thing I've been able to think of that might work would be to just duplicate the /wwwroot folder and name it /content, but that would require much manual effort to keep them synched as new images are uploaded or old images are replaced.

Did anybody else dream up a solution for this already?

Thanks,
Steve
6 years ago
Hello Steve,

Did you find any solution?

I've been facing same issue and I don't want to change with one by one product,topic,blog and    all..

So, if you found any solution than please help me.
5 years ago
embryo wrote:
Hello-
I'm wondering if it would be possible to just create some kind of rewrite rule in my web.config for image resource requests made from the /content directory? Or does that only work for page URL's??


With some help from Anton at nop-templates.com I have learned that it is possible to route requests made for resources in the /content/ folder to their new location in the /wwwroot/ folder using Regex pattern matching in the web.config:

<rewrite>
    <rules>
          <rule name="IMAGE_FOLDER_REDIRECT" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny">
           <add input="{HTTP_HOST}{REQUEST_URI}" pattern="(.*)[.](\w{2,3})(\/\w{2})?\/content\/(.*)" />
            </conditions>
            <action type="Redirect" appendQueryString="false" url="/{C:4}" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>


Note that this code does not affect requests made for resources in other site subfolders containing "/content/" in their URLs. Only requests made for resources in the /content/ folder in the root will be re-routed.
Examples of unaffected paths:
/themes/mycustomtheme/content/css/
/themes/mycustomtheme/content/views/
5 years ago
embryo wrote:
Hello-

With some help from Anton at nop-templates.com I have learned that it is possible to route requests made for resources in the /content/ folder to their new location in the /wwwroot/ folder using Regex pattern matching in the web.config:

<rewrite>
    <rules>
          <rule name="IMAGE_FOLDER_REDIRECT" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAny">
           <add input="{HTTP_HOST}{REQUEST_URI}" pattern="(.*)[.](\w{2,3})(\/\w{2})?\/content\/(.*)" />
            </conditions>
            <action type="Redirect" appendQueryString="false" url="/{C:4}" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>


Note that this code does not affect requests made for resources in other site subfolders containing "/content/" in their URLs. Only requests made for resources in the /content/ folder in the root will be re-routed.
Examples of unaffected paths:
/themes/mycustomtheme/content/css/
/themes/mycustomtheme/content/views/



Hello,

Grate, I am looking for exactly this rewrite rule.

+1

Thank you for your help.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.