<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Avinash Hegde</title>
    <description>The latest articles on DEV Community by Avinash Hegde (@avinashhegde6).</description>
    <link>https://dev.to/avinashhegde6</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F619060%2F90207311-5aba-49c2-a674-9e8853765e18.png</url>
      <title>DEV Community: Avinash Hegde</title>
      <link>https://dev.to/avinashhegde6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/avinashhegde6"/>
    <language>en</language>
    <item>
      <title>Nginx: How to redirect JS/CSS HTTP links to other domain?</title>
      <dc:creator>Avinash Hegde</dc:creator>
      <pubDate>Thu, 22 Apr 2021 13:16:35 +0000</pubDate>
      <link>https://dev.to/avinashhegde6/nginx-how-to-redirect-js-css-http-links-to-other-domain-5gh5</link>
      <guid>https://dev.to/avinashhegde6/nginx-how-to-redirect-js-css-http-links-to-other-domain-5gh5</guid>
      <description>&lt;p&gt;I have few HTTP links to the js/css files. I wanted to redirect it to other location. Example provided below:&lt;/p&gt;

&lt;p&gt;Redirection from:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ex.example.com/js/file1.js"&gt;https://ex.example.com/js/file1.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ex.example.com/css/file2.css"&gt;https://ex.example.com/css/file2.css&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ex.example.com/css/folder1/file3.css"&gt;https://ex.example.com/css/folder1/file3.css&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Redirection to:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ex2.example.com/js/file1.js"&gt;https://ex2.example.com/js/file1.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ex2.example.com/css/file2.css"&gt;https://ex2.example.com/css/file2.css&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ex2.example.com/css/folder1/file3.css"&gt;https://ex2.example.com/css/folder1/file3.css&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have tried below settings in nginx.conf. But its not working.&lt;/p&gt;

&lt;p&gt;server {&lt;br&gt;
    listen       443 ssl;&lt;br&gt;
    server_name ex.example.com;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;location / {
   return 301 https://ex2.example.com;
}
location ~* \.(css)$ {
    root https://ex2.example.com/css;
}
location ~* \.(js)$ {
    root https://ex2.example.com/js;
}
#location /css/ {
#   return 301 https://ex2.example.com/css;
#}
#location /js/ {
#   return 301 https://ex2.example.com/js;
#}

ssl_certificate      /etc/ssl/ssl-bundle.crt;
ssl_certificate_key  /etc/ssl/myserver.key;
client_max_body_size 5M;
ssl_prefer_server_ciphers   on;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}&lt;br&gt;
}&lt;br&gt;
Please help me with this.&lt;/p&gt;

</description>
      <category>nginx</category>
    </item>
  </channel>
</rss>
