locked
Link IIS root folder with local xampp wordpress RRS feed

  • Question

  • User572594905 posted

    Hi there!

    I'm using IIS 6.2 in a local server with different domains that points to a different local server folders that shows different websites (based on asp and html files). That's working fine, but now I would like to change one of these websites for a wordpress.

    To do that i've installed wordpress using xampp into another local server. That's working fine and I can access from the iis server to the wordpress server doing something like wordpresslocalip:8080

    What I would like to do it's to point one of the domains that it's currently on the IIS to the wordpress web so when someone tips the domain www.example.com the wordpress web will be showed instead the current asp file. Also I nedd to this only affects to the root document, not to others, example:

    www.example.com -> redirected to wordpress.

    www.example/test/welcome -> not redirected.

    Is there any way to achieve this with url redirection or changing the web.config file?

    Thanks a lot!

    Monday, March 8, 2021 10:21 AM

All replies

  • User1065476709 posted

    Hi Ecolt,

    www.example.com -> redirected to wordpress.

    www.example/test/welcome -> not redirected.

    You only need to create a url rewrite rule to meet these two conditions. here a link about the use of url rewrite module you can use as a reference: Creating Rewrite Rules for the URL Rewrite Module.

    If you still can't solve the question, please post details information about question, i will make demo for you.

    Best regards,

    Sam

    Tuesday, March 9, 2021 2:47 AM
  • User572594905 posted

    Hi samwu, thanks for the answer.

    I've tested with this rule but it's doing nothing

     <rule name="redirect" stopProcessing="true">
                    <match url="^$" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{HTTPS}" pattern="on" />
                          <add input="{HTTP_HOST}" pattern="^http://myweb.com$" />
                        </conditions>
                      <action type="Redirect" url="http://192.168.100.10:8080/" />
    </rule>

    Can you help me? what i'm doing wrong? I just need to myweb.com shows website that it's on the internal ip 192.168... but still showing myweb.com in the browser.

    thanks!

    Tuesday, March 9, 2021 9:26 AM
  • User572594905 posted

    I think what I need it's a reverse proxy? https://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/ point 7? 

    Tuesday, March 9, 2021 11:28 AM
  • User1065476709 posted

    Hi Ecolt,

    you help me? what i'm doing wrong? I just need to myweb.com shows website that it's on the internal ip 192.168... but still showing myweb.com in the browser.

    Do you want to redirect from http://myweb.com/page1.html to http://192.168.100.10:8080? if so, you can try this rule:

    <rule name="redirect" stopProcessing="true">
      <match url="^page1.html$" />
        <conditions>
          <add input="{HTTP_HOST}" pattern="http://myweb.com" />
        </conditions>
      <action type="Redirect" url="http://192.168.100.10:8080" />
    </rule>

    Best regards,

    Sam

    Wednesday, March 10, 2021 7:45 AM
  • User572594905 posted

    Hi samwu,

    I've been able to do it using this rule, but it's only works for the mainpage, once i'm on the wordpress and I press any other menu, it goes to the original domain 192.168.100.10:8080/newmenu

     <rule name="Proxy">
    <match url="(.*)" />
    <action type="Rewrite" url="http://192.168.100.10:8080/{R:1}" />
    </rule>

    Is there any way to keep always original domain and not only for the main page?

    Thanks!

    Wednesday, March 10, 2021 7:54 AM
  • User1065476709 posted

    Hi Ecolt,

    Is there any way to keep always original domain and not only for the main page?

    According to your description, I couldn’t understand your requirement clearly.

    Can you explain your question in detail?

    Best regards,

    Sam

    Wednesday, March 10, 2021 9:11 AM
  • User572594905 posted

    Hi samwu, i'll try to explain it better.

    I have a site (example.com) with some folders and subfolders with asp and html files inside, something like this:

    example.com

    root -> homepage.asp 

                  -> folder1 -> index2.asp

                  -> folder2 -> page3.asp

    I have created a wordpress site on other server in the network 10.34.100.10:8080.

    I do need to once you go to example.com it would be redirected to 10.34.100:10:8080 but keeping example.com domain and once you are in the wordpress it keeps the example.com url, for example once i'm in the wordpress if I go to other site inside the wordpress it should keep example.com, for example if I click on 'blog' it should show 'example.com/blog'

    I've been able to achieve this, with the following code but still have a problem, I do need that if someone goes to any of the original root folders it would not be redirected to the 192.168.100.10, so I need to the redirection only works into the root and not for the subfolders.

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <defaultDocument>
                <files>
                    <add value="homepage.asp" />
                </files>
            </defaultDocument>
            <rewrite>
                <rules>
                    <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                          <match url="^$" />

                        <action type="Rewrite" url="http://192.168.100.10:8080/{R:1}" />
                    </rule>
                </rules>
                <outboundRules>
                    <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^http(s)?://192.168.100.10:8080/(.*)" />
                        <action type="Rewrite" value="http{R:1}://example.com/{R:2}" />
                    </rule>
                    <preConditions>
                        <preCondition name="ResponseIsHtml1">
                            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                        </preCondition>
                    </preConditions>
                </outboundRules>
            </rewrite>
          
        </system.webServer>
    </configuration>

    Wednesday, March 10, 2021 9:22 AM
  • User1065476709 posted

    Hi Ecolt,

    I've been able to achieve this, with the following code but still have a problem, I do need that if someone goes to any of the original root folders it would not be redirected to the 192.168.100.10, so I need to the redirection only works into the root and not for the subfolders.

    You can use parameters in the rule to restrict, let it only works into the root and not for the subfolders.

    For example, in your rule "^$" only matches empty, but you can use specific parameters to make it match only the root.

    Best regards,

    Sam

    Thursday, March 11, 2021 9:36 AM
  • User690216013 posted

    I've tested with this rule but it's doing nothing

     <rule name="redirect" stopProcessing="true">
                    <match url="^$" />
                        <conditions logicalGrouping="MatchAny">
                            <add input="{HTTPS}" pattern="on" />
                            <add input="{HTTP_HOST}" pattern="^http://myweb.com$" />
                        </conditions>
                        <action type="Redirect" url="http://192.168.100.10:8080/" />
                    </rule>

    Mistake 1 in The Very Common Mistakes When Using IIS URL Rewrite Module – The Half-Blood Programmer – Stories from Lex Li on technologies. (lextudio.com)

    If your goal is to issue 30x redirection responses, you don't need to set up a reverse proxy.

    Friday, March 12, 2021 12:20 AM