Call Us: 992 9441 754

Configuring WHM mod_rewrite and mod_userdir – Step-by-Step

< All Topics

Configuring WHM mod_rewrite and mod_userdir – Step-by-Step

To configure mod_rewrite and mod_userdir in WHM (Web Host Manager), follow these steps. These modules are used to enable URL rewriting and user directory access in Apache web servers.

Enabling mod_rewrite in WHM

mod_rewrite is an Apache module that allows for URL rewriting. This is useful for creating clean, user-friendly URLs and for redirecting requests.

1. Log in to WHM:

      • Access WHM by navigating to http://yourdomain.com/whm and logging in with your credentials.

      2. Ensure mod_rewrite is Enabled:

        • Go to the Apache Configuration section.
        • Select Global Configuration.
        • Ensure that mod_rewrite is listed under the “Loaded Modules” section. If it is not, you may need to rebuild Apache with mod_rewrite included.

        3. Rebuild Apache with mod_rewrite:

          • Navigate to EasyApache 4.
          • Customize your profile.
          • In the Apache Modules section, search for mod_rewrite and ensure it is selected.
          • Save and provision the profile to rebuild Apache with the selected modules.

          Enabling mod_userdir in WHM

          mod_userdir is an Apache module that allows users to access their web content using URLs like http://yourdomain.com/~username.

          1. Log in to WHM:
            • Access WHM by navigating to http://yourdomain.com/whm and logging in with your credentials.

            2. Enable mod_userdir:

              • Go to the Security Center section.
              • Click on Apache mod_userdir Tweak.
              • Enable the mod_userdir protection by unchecking Enable mod_userdir Protection. This will allow access to user directories via ~username.

              3. Configure User Directories:

                • You can configure specific user directory access and exceptions in the same section. This is useful if you want to allow or restrict user directory access for certain users or IP addresses.

                Example .htaccess for mod_rewrite

                To use mod_rewrite, you typically need to create or edit a .htaccess file in your web directory. Here is an example of a basic .htaccess file to rewrite URLs:

                • RewriteEngine On: Enables the rewrite engine.
                • RewriteCond: Conditions to check before applying the rewrite rule.
                • RewriteRule: The rule to rewrite the URL.

                Example Configuration for mod_userdir

                To configure user directory access, you can use the Apache configuration file. Here is an example configuration snippet:

                • UserDir public_html: Specifies the directory name within the user’s home directory that contains their web files.
                • UserDir disabled root: Disables user directory access for the root user.
                • UserDir enabled user1 user2: Enables user directory access for user1 and user2.

                Summary

                By enabling and configuring mod_rewrite and mod_userdir in WHM, you can take advantage of Apache’s powerful URL rewriting and user directory features. This configuration allows for cleaner URLs and provides user-specific web directories, enhancing the flexibility and usability of your server.

                Categories

                Recent Comments

                No comments to show.