I found that mod_rewrite function is not enabled on my server(_SERVER["SERVER_SOFTWARE"] -Microsoft-IIS/7.0),Architecture x86 .How can I enabled the mod_rewrite.Could any one please help me.
- Is it enabled in the php.ini file?tuespetre– tuespetre2012-12-11 06:24:40 +00:00Commented Dec 11, 2012 at 6:24
- Did I edit the php.ini file on my server.?rms– rms2012-12-11 06:25:44 +00:00Commented Dec 11, 2012 at 6:25
- What is your architecture? Linux or Windows? Which web server?shapeshifter– shapeshifter2012-12-11 06:30:53 +00:00Commented Dec 11, 2012 at 6:30
- 1Big fat heads up to everyone now reading this: it was not always stated that this was on IIS, not Apache. The answers about Apache were right at the time.Charles– Charles2012-12-12 09:19:11 +00:00Commented Dec 12, 2012 at 9:19
4 Answers
The answer that worked for me was to install the Microsoft URL Rewrite module and then create a web.config file in the root of the site with this in it (the rules):
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Security Rule" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAny"> <add input="{QUERY_STRING}" pattern="mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" ignoreCase="false" /> <add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" ignoreCase="false" /> <add input="{QUERY_STRING}" pattern="(\<|%3C).*script.*(\>|%3E)" /> <add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" /> <add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" /> </conditions> <action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" /> </rule> <rule name="SEO Rule"> <match url="(.*)" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" pattern="" ignoreCase="false" /> <add input="{URL}" negate="true" pattern="^/index.php" ignoreCase="false" /> <add input="{URL}" pattern="(/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$" /> </conditions> <action type="Rewrite" url="index.php" /> </rule> </rules> </rewrite> </system.webServer> </configuration> Comments
If your hosting at a commercial hosting provider they will most likely have the Microsoft URL Rewrite module installed. This gives you similar functionality to the Apache mod_rewrite module.
To test if this module is installed, create a file called web.config in the root of your website with the content below and try to http://www.domain.com/google where domain.com is your website's domain. If you get redirected to google.com your host has the URL rewrite module installed.
web.config:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <clear /> <rule name="Redirect to google.com" stopProcessing="true"> <match url="^google$" /> <action type="Redirect" url="http://www.google.com/" appendQueryString="false" /> </rule> </rules> </rewrite> </system.webServer> </configuration> Comments
1) find httpd.conf (usually this file can be found in folder callled conf , config or something along those lines)
2) Find and uncomment the line LoadModule rewrite_module modules/mod_rewrite.so
3) Find the line with DocumentRoot “C:/path/to/my/root”, There you will find contents like
Make sure the content inside these two braces looks like
Options All
AllowOverride All
4) All done now restart the Apache server and you will be all good to go
1 Comment
/etc/httpd/ or /etc/apache2There is no free version of mod_rewrite for LINUX available for the Windows OS. The only way out that I found was to import a .htaccess file on IIS using URL REWRITE, which is freely available on the Web Platform Installer.
After installing the URL REWRITE component, follow the steps on the link below to import the .htaccess file and create its windows equivalent, the web.config file.
http://www.iis.net/learn/extensions/url-rewrite-module/importing-apache-modrewrite-rules
Cheers.