Wednesday, November 13, 2024

Htaccess WordPress In IIS Windows

Usually if we want to setup wordpress  in Linux environment, then we can use .htaccess in our home directory. The .htaccess file should contained below:


# BEGIN WordPress
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

But, how about if we want to set the WordPress in IIS / Windows environment? Of course we can! Because of .htaccess is not supported in Windows Environment, then we can use web.config instead. You can create new file called “web.config” and fill it as below:

<?xml version=”1.0″?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<remove value=”index.php” />
<add value=”index.php” />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name=”Main Rule” stopProcessing=”true”> <match url=”.*” />
<conditions logicalGrouping=”MatchAll”>
<add input=”{REQUEST_FILENAME}” matchType=”IsFile” negate=”true” />
<add input=”{REQUEST_FILENAME}” matchType=”IsDirectory” negate=”true” />
</conditions>
<action type=”Rewrite” url=”index.php/{R:0}” />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

After that, put all the wordpress file as usual as in linux. Make sure php and mariadb are installed.