Configure web.config for Mautic on IIS to mimic htaccess

I installed php application called mautic on windows server 2008 R2 with IIS.

I am having trouble with the url exactly as indicated in the link below. I believe solution below is for apache. Can any of php gurus help with this for IIS?

https://www.mautic.org/community/index.php/441-index-php-should-it-be-part-of-root-url/0
dreamer123456Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
It sounds like you need to update your web.config file. I didn't see any info on web.config files on the site. I will download it and see if it is in the zip file.
0
dreamer123456Author Commented:
It is not in the zip file. IIS auto generated web.config file. I tried importing settings from htaccess to web.config file. It couldnt import 4 out of  5 settings since there were some environment variables.
I tried HTTP redirect in IIS, it goes in endless redirect loop.
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Just quickly browsing, I found this https://www.mautic.org/community/index.php/2667-installing-mautic-on-azure-websites
<rule name="Rewrite to index.php 2">
      <match url="^([_0-9a-zA-Z-]+)?(\/[_0-9a-zA-Z-]+)?$" ></match>
      <conditions>
            <add input="{URL}" negate="true" pattern="index.php(.*)" ></add>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" ></add>
      </conditions>
      <action type="Rewrite" url="index.php/{R:1}/{R:2}" ></action>
</rule>

Open in new window

I am running out of time now, but I will try and install this on my site later today and see what works.
0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I never had any luck using the import tool
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
What directory do you have this installed in? Top level (mydomain.com) or something like mydomain.com/mautic/
0
dreamer123456Author Commented:
Scott,

Solution in your link worked but the initial load of the website is pretty slow. Will this work once SSL is installed?
0
dreamer123456Author Commented:
Scott,

solution on the link you sent worked. Its really slow to load but it works. Will this work with https as well?

Regards,
Virendra
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I have not had a chance to try it out yet.  It is hard to say what is causing the speed issue.  Are you using this locally on your own computer vs a server?  Moving to a server will speed things up.  Otherwise, do you know how to use the browser dev tools?  You can view speed issues that way. There could be something hanging.
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
What I suggest at this point is to close out this question because we solved the issue of configuring iis/web.config file.   Then ask a new question for the speed issue. This keeps each problem in it's own thread.  I had the question title changed to match what you wanted as it will make it easier for others to find with a similar issue (using mautic on iis).

In your new question, select topics for php, windows server, iis, web server.  If you can include a screen shot of your dev tools that shows any errors. Also let us know if you are on windows 10 or a server.
0
dreamer123456Author Commented:
On further testing. This only works for the home page. Internal links within the application do not work.
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I noticed there are  htaccess files throughout the app.  Also, more details will help here. What do you mean by does not work?  What do the urls look like at the top level of the app vs interior?  Are you running the app at the top level of your domain or sub folder? If sub folder what is the url of the app home page?  If you right click on the page and then select, "inspect" you will get to the browser console. There should be a tab called, "console".  Click on that and refresh the page.  Are any errors showing up there?  If not, go to the tab marked, "network" and refresh the page again.  You will see all the pages and elements that load. Most should have code of 200 or 302. Are there any lines with code 500 or in red?  In the time column do you see anything unusually high?
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I installed this locally and did run into some troubles with permissions.

On the top right there is a gear. Click that to go to system info, then click file and folder permissions and I saw I had some folders that were not set correctly.  I can see a slight delay but I think that is because I am running locally as opposed to my web server.

I am seeing what you are talking about. I have my site set to http://localhost:81 and that redirects to http://localhost:81/s/dashboard and it should redirect to http://localhost:81/index.php/s/dashboard.  Is this what you want?
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
I think I have it.   Looking here https://www.mautic.org/community/index.php/2667-installing-mautic-on-azure-websites/0 I modified and came up with

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <customErrors mode="Off" />
    </system.web>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".woff" />
            <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
            <remove fileExtension=".woff2" />
            <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
        </staticContent>
        <rewrite>
            <rules>
                <rule name="Rewrite to index.php">
                    <match url="^([_0-9a-zA-Z-]+)/([_0-9a-zA-Z-]+)$" />
                    <conditions>
                        <add input="{URL}" negate="true" pattern="index.php(.*)" />
                    </conditions>
                    <action type="Rewrite" url="index.php/{R:1}/{R:2}" />
                </rule>
            </rules>
            <rewriteMaps>
                <rewriteMap name="/" defaultValue="/s/dashboard" />
            </rewriteMaps>
        </rewrite>
    </system.webServer>
</configuration>

Open in new window


It now seems to redirect nicely.    If I go to  http://localhost:81 I am redirected to http://localhost:81/s/dashboard.   In my case I had to use port 81 and in your site you may just have mysite.com  which is the same as mysite.com:80.  

I did run into some other errors installing.    The installer was not reading the memory limit correctly and I ended up hard coding but I can't remember where that is now.

I hope this one works for you.
0
dreamer123456Author Commented:
I will try this tomorrow. Are you able to login, click on configuration on right top side and add or edit users within mautic application? This will tell us if internal links are working as well.
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Right on, good catch. That didn't work.

This one does. It is similar to what I use for the php micro frameworks

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <customErrors mode="Off" />
    </system.web>
    <system.webServer>
        <staticContent>
            <remove fileExtension=".woff" />
            <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
            <remove fileExtension=".woff2" />
            <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
        </staticContent>
        <rewrite>
            <rules>
                <rule name="mautic" patternSyntax="Wildcard">
                    <match url="*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
            <rewriteMaps>
                <rewriteMap name="/" defaultValue="/s/dashboard" />
            </rewriteMaps>
        </rewrite>
    </system.webServer>
</configuration>

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dreamer123456Author Commented:
Thank you.
1
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
For the speed issue, I did see a couple of things using the browser dev tools. One is loading the gravitar and the other is an ajax request that looks like it updates your logged in status. Each took about 800ms on first load. After that it was faster. Again, I am running locally and that will not be as fast as a web server so I don't know if those things are the real issue or not.

I am was happy to work on this because it is a new product to learn about.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.