mod_rewrite to IIS URL Rewrite XML syntax - iis

I have some trouble translating these rewrite rules to IIS URL Rewrite XML syntax.
RewriteEngine On
RewriteCond %{REQUEST_URI} /wp-content/uploads/
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteRule (.*) %{DOCUMENT_ROOT}/wp-content/plugins/ack_auto_image_resize/ack_generate_image.php?uri=$1 [L]
Anyone got any ideas? =)

IIS 7 will do the conversion for you.
Double-click on the URL Rewrite feature for the site
On the right choose "import rules"
Paste the rules into the "Rewrite Rules" block
Apply
I have used this method with several rewrite rule sets with no issues.

Related

PHP Dynamic URL Parameters and GET

I'd like to ask if it's possible to use a dynamic url and GET at the same time.
Let's say my current dynamic url is: https://yourdomain.com/blog/this-is-a-title
Would it be possible to make this work too: https://yourdomain.com/blog/this-is-a-title?action=delete
RewriteEngine on
RewriteRule ^([0-9]+)$ index.php?id=$1
The dynamic url mentioned first works fine, but I want to make the second work as well.
This is my .htaccess - hope it helps.
PS: I know that the regex in my htaccess isn't correct, it's just an example.
Have your .htaccess Rules file in following manner. Please make sure that your htaccess Rules file is present in root folder(where blog and htaccess both are residing in it; htaccess shiouldn't be inside blog folder; should be place same folder with it). Make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
##Newly added rules here...
RewriteBase /blog/
RewriteCond %{THE_REQUEST} \s/blog/(?:[^?]*)?action=(\S+)\s [NC]
RewriteRule ^ index.php?action=%1 [L]
##Old Rules OP's htaccess ones.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)$ index.php?id=$1

ISAPI Rewrite conversion

I have an existing site that uses ISAPI Rewrite by way of the .htaccess file. I am moving to a new host also on a Windows server and have been told that my rules must be loaded to the web.config file.
So the old rules looked like this:
RewriteBase /
RewriteMap mapfileNews txt:mapfile/mapfileNews.txt
RewriteCond %{QUERY_STRING} ^ArticleID=[^&]+&n=(.+)
RewriteRule ^pages/ndetail\.asp$ news/%1? [NC,R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^news/([^/]+)$ pages/ndetail.asp?
ArticleID=${mapfileNews:$1}&n=$1 [NC,L]
So what the rule is doing is opening the mapfileNews.txt file, grabbing the ID number and mapping it to an article name. Like:
http://www.website.com/pages/ndetail.asp?ArticleID=7
being rewritten to something like
http://www.website.com/news/article-name
I have no idea how to convert this over so it works in my web.config file.
And please excuse me for my noobness. I'm not tecchy at all :(

Need help in URL rewrite rules

The URL rewrite condition is always taking me to the index file, i dont know why, below is my case.
my link is:
http://www.anabrokers.com/contents_12/Selling%20Your%20Business
my htaccsess contains the following:
RewriteEngine On
RewriteCond %{REQUEST_URI} contents_
RewriteRule ^(.*)$ /Home/contents.php/?$ [NC,L]
Tips:
Hosted on Godaddy
PHP version 5.3.24

.htaccess rules work in XAMPP but not on IIS 6

I use .htaccess rewrite rules to redirect urls with the extension .html to .php.
These are my current rewrite rules:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html$ a/$1.php [NC]
How do I get these to work on IIS6?
Apache (which is the web server in XAMPP) .htaccess (mod_rewrite) rules won't work on IIS6. You need to install a third party rewriter such as HeliconTech's ISAPI_Rewrite to achieve this.
IIS7+ supports rewriting out of the box but the format is different.

Simple URL rewrite does not work

First, I know there are several questions of this, but what I experience is that other rules work, like removing the .php extension while this rule does not work:
RewriteRule ^hello$ marketplace [NC,R=301]
This is just a simple test, and it's not working. The URL is still marketplace and not hello. And I have tried to remove all other rules I have and let the rule above be the only existing in my htaccess file, but still, not working.
Any ideas? mod_rewrite is clearly turned on because other rules work.
Tested and not working:
RewriteRule ^marketplace$ /hello [NC,R=301]
Highly recommend you to give a read on this "Apache mod_rewrite Introduction"
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.*)\.php [NC]
RewriteRule ^ /%1 [R=301,QSA,L]
# Redirect to hello
RewriteRule ^marketplace$ /hello [R=301,NC,L]
# Show the content of marketplace on hello
RewriteRule ^hello$ /marketplace.php [NC,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^([^/]+)/?$ $1.php [L]
The above is a fully tested and working rule.
First rule will redirect .php to directory like URL's for example domain.com/marketplace.php becomes domain.com/marketplace.
Second rule redirects marketplace to hello.
Third rule internally redirect hello to marketplace.php so the URL remains hello with the content of marketplace.php.
Last rule will verify it directory does not exist but exist as a php file and internally redirect to it.
So if you access marketplace.php it goes to marketplace then hello and from hello you will see the content of marketplace.php.
If marketplace.php does not exist then you get 404 error.

Resources