IIS Url Rewrite Add Index.php to - iis

I have problem with IIS and url rewrite...
I'm getting urls like this
http://www.mywebsite.com/this-is-my-article
I need to rewrite it to
http://www.mywebsite.com/index.php/this-is-my-article
I was trying patterns and conditions that in theory should work, but they don't. After few hours of searching and trying I decided to ask you for help.
Could anyone tell me, how to set URL Rewrite module?
best regards
M

You can try this rule, if you have any questions, please let me know.
<rule name="test1">
<match url=".*$" />
<action type="Rewrite" url="index.php/{R:0}" />
</rule>

Related

IIS URL Rewrite with Incoming URL

I have a strange business case where I need any time a URL is called on my web server that it is re written with the incoming URL.
Example:
Incoming URL
/site/1
URL that it is going to
/innerlink/2
In the browsers URL
/innerline/2 would show /site/1
If you can answer this question or get me to some material that could help me in doing this it would be greatly appreciated. Thanks!
The name of this approach "URL rewriting". In IIS you can achieve it with URL rewrite module.
In your case when you just need to rewrite /site/1 to /innerlink/2 you need to do the following:
Install URL rewrite module for IIS (it might be already installed)
In your web.config you need to add this rewrite rule:
.
<rule name="Laravel5" enabled="true" stopProcessing="true">
<match url="^site/1$" />
<action type="Rewrite" url="/innerlink/2" />
</rule>
And now if you will open in your browser this link {YOUR DOMAIN, IP OR HOSTNAME}/site/1 it will make request to /innerlink/2 (but browser will keep showing /site/1)
P.S. Also you can find some useful rewrite/redirect rules in this article: https://host4asp.net/top-iis-rewrite-rules/

IIS URL Rewrite to correct an bad url

I have a bad url coming in as
http:/example.com/path/file.html how
How can I fix it to be
http://example.com/path/file.html how
Notice the http:\ to http:\\
I don't want to fix it for just a single url, would like to be fixed for all urls that happen to have an error IIS URL Rewrite.
I coded many URL Rewrites before, but for some reason I can't figure this one out.
I think I figured it out, there might be a better way, but this seems to fix the issue.
<rule name="Fix Slash Issue" stopProcessing="true">
<match url="^(http.?:\\[a-zA-Z0-9])" />
<action type="Redirect" url="https:\\{HTTP_HOST}\{REQUEST_URI}" />
</rule>

Replace a word using IIS URL Rewrite

I am using the IIS Rewrite module with my web.config, and would like to rewrite certain requests by replacing a word in the URL.
Example: http://domain.com/windows to be http://domain.com/WINDOWSSoftware
I'm aware that a URL with query string parameters can be rewritten using for example below rule
<rules>
<rule name="Rewrite to article.aspx">
<match url="^article/([0-9]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="article.aspx?id={R:1}&title={R:2}" />
</rule>
</rules>
Instead of /article?id=243&title=some-title we can have /article/234/some-title
I'm wondering if this can be achieved using URL Rewrite, or can it be done by developing a custom provider.
This can definitely done with url rewrite module with bit of regex pattern matching.
http://domain.com/windows/sdfsdf
so if you just match {R:1} or {C:1} depending on how you setup
The final redirect can look like
{HTTP-HOST}/WindowsSoftware/{R:2}

Custom URL Rewriting in Classic ASP

I have been trying to rewrite the URL in classic ASP. I am currently using IIS 7.5. I tried to use the URL Rewrite plugin which converts the following link:
http://blog.johnavis.com/blog/default.asp?id=19
into something like this:
blog.johnavis.com/19/
blog.johnavis.com/id/19/
blog.johnavis.com/blog/default/19
blog.johnavis.com/blog/default/id/19
I want to convert into something like this:
http://blog.johnavis.com/blog/myblog/
Can that be achieved? Any help would be appreciated.
Basically all the rewrite module does is to edit your web.config file. You're probably better off editing the file yourself. You'll find that it has created a section called rewrite, add the following rule
<rewrite>
<rules>
<rule name="My Blog">
<match url="blog/myblog/" />
<action type="Rewrite" url="blog/default.asp?id=19" />
</rule>
</rules>
</rewrite>
You can achieve this by creating URL rewrite rule in IIS Manager by defining a pattern. Use the following links to learn about that.
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-video-walkthrough
Hope this helps...

IIS Throwing HTTP 500 for rewrite rules

When I put my web.config into any folder/main directory it seems to be throwing the HTTP error code: 500--unfortuenly I don't have access to the logs so I can't see why, so surely it's down to my web.config - I've never used IIS before but I'm trying to re-route all requests to a file called 'api.php', here's my web.config file.
<rewrite>
<rules>
<rule name="rule 1Q">
<match url="^/.*" />
<action type="Rewrite" url="/api.php" />
</rule>
</rules>
</rewrite>
Apache equivalent:
RewriteEngine on
RewriteRule ^/.* /api.php
Any help is greatly appreciated.
This is not an exact answer because I am not sure of your server variables but here is something that might be useful to you. Here. This walks through the IIS set up for version 7 and it has some basic concepts. There is rewrite module/tool that could help but I haven't used it. And another document here...Shows the GUI interface like the first link and is in 7.5.
Again not specific solutions but hopeful you have some server gurus there that can help you at least get the IIS settings right (or at least not sound dumb if you have to communicate something specific to them) if this is a first time IIS Isapi venture for you.

Resources