Rewrite web server apache for IIS - iis

I need to translate htaccess rewrite rule for a IIS web server, can you help me with the sintax? for example:
RewriteCond %{QUERY_STRING} ^orderby=([0-9]+)&pagesize=([0-9]+)&pagenumber([0-9]+)$
RewriteRule ^[OLD-SLUG]$ https://www.[DOMAIN].it/[NEW-SLUG]? [R=301,L]
Or:
RewriteRule ^[OLD-SLUG]$ - [G]
Thanks

Many PHP applications currently ship with rewrite rules as part of their .htaccess file. These rules tell Apache's mod_rewrite how and when to rewrite incoming requests. The IIS URL Rewrite module can read these rules and translate them into URL Rewrite rules.
For more information about importing Apache mod_rewrite rules, see: Importing Apache mod_rewrite Rules.

Related

How do I create an Nginx rewrite to enforce lowercase urls?

I've been given a request from a client to ensure all visits to their site are to lowercase URLs following an external SEO audit.
For example they'd like www.example.com/How-We-Help to redirect with a 301 code to www.example.com/how-we-help
Their site is hosted on WPEngine - I know this would be a simple thing to do using htaccess rules but htaccess has been deprecated on WPEngine for a little while now.
Example htaccess rule
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule . ${lc:%{REQUEST_URI}} [R=301,L]
I've read that it is possible to create a similar rule with Nginx rewrites but my knowledge is limited and WPEngine support weren't much help.
Is a way to do this using Nginx rewrites? If so, what rules need to be in place?

htaccess not working in iis

friends. I'm creating an .htaccess file with rewrite rules. It's working fine in localhost, but on the live, server it's not working. My hosting uses a Window server.
I wrote this Rule in my .htaccess file:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
By default, IIS does not support .httacces and Apache mode_rewrite rules. To achieve this, you will have to install Helicon Ape addon along with IIS. Helicon Ape offers support for the Apache .htaccess and .htpasswd configuration files in Microsoft IIS.
With Helicon Ape you can use modules, like mod_rewrite, mod_proxy, mod_auth, mod_gzip, mod_headers, mod_cache, mod_expires, mod_replace and others under single IIS addon. Single website license for Helicon Ape will cost you $47 one time.
If you want to have free alternative, you can go with native IIS URL Rewrite Module. Microsoft URL Rewrite module offers similar functionality like Apache mod_rewrite module with the help of web.config file. You can simply install this module and import your .httacces rules to IIS web server. This module also lets you convert the existing Apache mod_rewrite rules to IIS URL rewrite rules and store them to web.config automatically. For more information, refer to following tutorial.
https://manage.accuwebhosting.com/knowledgebase/2415/How-to-Enable-modrewrite-on-IIS-Web-Server.html

Rewrite rule .htaccess for my sitemap.xml

I have a content management system plugin installed that provides a sitemap for Google under http://www.domain.com/index.php?eID=dd_googlesitemap how can I add a rewrite rule to my .htaccess that will make this sitemap available under http://www.domain.com/sitemap.xml instead?
You can add this code to your htaccess file (which has to be in root folder)
RewriteEngine On
RewriteRule ^sitemap\.xml$ /index.php?eID=dd_googlesitemap [L]
Make sure mod_rewrite is enabled

.htaccess rewrite a url to a subdomain

I don't think this is possible, however I would like to ask the community to see if it is.
I have a blog on a subdomain blog.domain.com due to a revamp of the site we are having to use the blog on a trailing domain domain.com/blog this isnt ideal as all our old post permalinks point to the subdomain.
I was therefore wondering if there is a way to use the .htaccess to rewrite domain.com/blog -> blog.domain.com
Any help would be greatly appreciated.
I believe you want to redirect all the traffic from blog.domain.com to domain.com/blog. Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(blog)\.(domain\.com)$ [NC]
RewriteRule ^ http://%2/%1%{REQUEST_URI} [NE,R=302,L]
Once you verify it is working fine, replace R=302 to R=301. Avoid using R=301 (Permanent Redirect) while testing your mod_rewrite rules.

Transfer ISAPI_Rewrite code to Built-In IIS7 Rewrite Engine

I've transferred my IIS6-based website to IIS7. It uses ISAPI Rewrite. I want to use the built in IIS7 rewrite engine. I have the following code in my httpd.ini file:
[ISAPI_Rewrite]
RewriteRule /httpd(?:\.ini|\.parse\.errors).* / [F,I,O]
RewriteRule ^(.*)$ http://www.workcity.co.il/$1 [R,R=301]
RewriteRule /([^/.?]+) /sc.asp?p=$1 [I,L]
RewriteRule /products/([^/.?]+) /sp.asp?p=$1 [I,L]
RewriteRule /מוצרים/([^/.?]+) /sp.asp?p=$1 [I,L]
But it dosen't work in IIS7 Rewrite Engine.
What is different in the IIS7 rewrite engine between ISAPI Rewrite, and how can I fix it?
Thanks.
Importing Apache mod_rewrite Rules
IIS Uses a seperate downloadable plug that will first need intalling.
Once that is complete, you just need to convert the RegEx ISAPI rules above to work with IIS7.
The RegEx principles and logic will be very similar, you'll just need to convert the syntax.
Theres a lot of info on the IIS.net site that will help you convert the rules.
http://learn.iis.net/page.aspx/460/using-url-rewrite-module/
I hope that helps

Resources