Link to home
Start Free TrialLog in
Avatar of Chad K
Chad K

asked on

How do I create a URL Rewrite rule in Apache based on IIS directions

Hello-

I am trying to setup autodiscover on my domain following directions from SmarterTools.  These directions only lay out a method based on your website being housed on IIS.  We use Plesk and Apache for our website.  I have detailed directions on how to setup a URL Rewrite rule in IIS, but I have no idea how to do that same rule in my Plesk/Apache environment.  Plesk says I can create rules in Apache Additional Directives (How to enable Apache or Nginx rewrite rules in Plesk? – Plesk Help Center), but I don't know how I would go about creating this specific rule in for my domain?  The directions for the rule in IIS are as follows:

Create a URL Rewrite within IIS
Follow these steps if you'd like to add the rewrite rule by creating a URL Rewrite within IIS:
(Note: These instructions are for IIS 10. Steps may vary when using a different version of IIS.)
  1. Log in to the server that hosts your company website. 
  2. Install the extension, URL Rewrite Module 2.0. For assistance and more information, see Using URL Rewrite Module 2.0
  3. After the URL Rewrite Module has been installed, open Internet Information Services (IIS) Manager.
  4. In the navigation pane, expand the server name folder and Sites folder. Click on the site that's used for your company website.
  5. In the preview pane that lists the site features, under the IIS section, double-click on URL Rewrite.
    User generated image
  6. In the righthand Actions pane, click on Add Rules....
  7. Under the Inbound rules section, click on Blank rule.
  8. The Edit Inbound Rules window should be modified with the following parameters:
    User generated image
    • Name: Redirect rule1 for /autodiscover/autodiscover.xml
    • Requested URL: Matches the Pattern
    • Using: Regular Expressions
    • Pattern: .*
    • Ignore case: Enabled
    • Conditions
      • Logical Grouping: Match All
      • Click Addto create a new condition:
        • Condition Input: {/autodiscover/autodiscover.xml:{REQUEST_URI}}
        • Check if input string: Matches the Pattern
        • Pattern: (.+)
        • Click OK to submit the new condition. 
      • Track capture groups across conditions: Disabled
    • Server Variables: None
    • Action
      • Action Type: Redirect
      • Action Properties
        • Redirect URL: {C:1}
        • Append query string: Disabled
        • Redirect type: Permanent (301)
  9. In the righthand pane, click Apply to save the Inbound Rule. 
  10. After the Inbound Rule has been configured, perform an IIS reset.


How can I replicate this rule in Apache?  Thanks!


Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Hi Chad,

You can follow the guideline how to setup domain forwarding 301 in plesk environment:
https://www.websavers.ca/setup-301-redirect-plesk-use/amp

Please share more information for your plesk / apache version if you need further assistance on setup the url directs from your existing IIS settings.
Avatar of Chad K
Chad K

ASKER

Ok, so I have a redirect rule in the .htaccess file which works.  This rule looks like the following:

RedirectMatch 301 (?i)^/autodiscover/(.*)$ https://mail.joink.com/autodiscover/$1

It redirects anything pointed at http://mydomain.com/autodiscover/autodiscover.xml to https://mail.joink.com/autodiscover/autodiscover.xml.  Is this the most efficient way to accomplish this, or should I be writing the rule in the nginx settings or Additional Apache directives on the site itself?  If the latter is correct, how would I change this rule so that it would work under the "Additional Apache directives" instead of in the .htaccess file?
In general, you should only use .htaccess files when you don’t have access to the main server configuration file.

htaccess files should be used in a case where the content providers need to make configuration changes to the server on a per-directory basis, but do not have root access on the server system


Avatar of Chad K

ASKER

Thanks for the advice. how would I change the htaccess rule into one that would fit “Additional Apache Directives” in my case?
ASKER CERTIFIED SOLUTION
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial