I need to add a .html file to a Wordpress installation that works on IIS.
What I have now is:
//mydomain.com/userpage.html
What I want to achieve is:
//mydomain.com/userpage/
I fixed all the other rules (pretty urls and so on...) but which code should I use to achieve the above result?
Thank you!
Max
Your rule should be like that:
<rule name="hide userpage.html">
<match url="^userpage/?$" />
<action type="Rewrite" url="/userpage.html" />
</rule>
Related
I want to include the PSR12 ruleset (which includes the rule "PSR1.Methods.CamelCapsMethodName.NotCamelCaps") but I don't want that rule to run on a specific file. so I tried the following ruleset:
<rule ref="PSR12">
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
</rule>
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>packages/test/file</exclude-pattern>
</rule>
Unfortunately, it doesn't run the "PSR1.Methods.CamelCapsMethodName.NotCamelCaps" rule at all (also not in the rest of the code).
Does anyone know how to get this working?
As #Greg Sherwood gave the solution: I could just remove the tag from the PSR12 rule.
<rule ref="PSR12">
</rule>
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
<exclude-pattern>packages/test/file</exclude-pattern>
</rule>
you can also try this....
<rule ref="PSR12">
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
</rule>
The path of this You find out from
/usr/share/php/PHP/CodeSniffer/Standards/PSR1/Docs/Methods
I'm currently researching how to implement URL Rewriting and was wondering if someone could help shed some light.
Our current url structure is the following..
http://example.com/products.cfm?id=1234
http://example.com/recipes.cfm?id=6789
I would like to configure IIS so that URLs can be rewritten to the following (or similar)
http://example.com/products/1234/product-title-here
http://example.com/recipes/6789/yummy-recipe-ever
How would I go about doing this?
Read through this walk through. The example comes close to what you want (replaced aspx with cfm).
<rewrite>
<rules>
<rule name="Rewrite to article.aspx">
<match url="^article/([0-9]+)/([_0-9a-z-]+)" />
<action type="Rewrite" url="article.cfm?id={R:1}&title={R:2}" />
</rule>
</rules>
</rewrite>
Look into Coldbox there is a rewrite.ini and IS7 web.config included
http://wiki.coldbox.org/wiki/URLMappings.cfm
The Coldbox blog shared this link
http://blog.coldbox.org/blog/coldbox-and-url-rewrites-with-iis-7
having a bit of trouble here, I'm working on a web.config file to perform a URL redirect from a file to a folder. I have the following:
<rule name="redirect fleet/cats.asp" stopProcessing="true">
<match url="^fleet/cats.asp$" ignoreCase="false" />
<action type="Redirect" redirectType="Permanent" url="http://www.ccy.com.au/availability/{R:1}" />
</rule>
Which redirects:
/fleet/cats.asp to /availability/cats.asp
What I want to achieve is:
/fleet.cats.asp to /availability/
What am I missing to achieve this? Any help would be greatly appreciated, thank you in advance!
I found that I had to remove {R:1} on the action attribute. that way I can redirect from a page to a directory. Thanks me!
I have been struggling with the following for quite some time now:
Default url:
examplesite.com/folder/about.cshtml
Desired url:
examplesite.com/about
Basically I want to accomplish two things:
1 Remove the file extension with realtively compact code.
2 Remove the folder that houses the about page.
I have found some uncommon rules to achieve all the above, but they mostly contain a lot of redundant code that crashes my site when I test it with IIS 8.0.
So I was hoping someone could share a rule that is compact and fits my needs. Or seperate rules with the same outcome.
Every contribution is much appreciated :)
I'm not certain I entirely understand your needs, but here's something that's at least close. It strips out the first folder and file extension (so examplesite.com/folder/about.cshtml becomes examplesite.com/about and examplesite.com/folder/help/about.cshtml becomes examplesite.com/help/about). If you wanted to strip all folders then just remove the ?.
<rule name="Remove Directory and Extension">
<match url="^(.*?)/(.*)\.cshtml$" />
<action type="Rewrite" url="{R:2}" />
</rule>
Update:
Ok, I think what you want is a combination of two rules then:
<rules>
<rule name="Redirect requests to friendly URLs">
<match url="^(.*?)/(.*)\.cshtml$" />
<action type="Redirect" url="{R:2}" />
</rule>
<rule name="Rewrite friendly URLs to phsyical paths">
<match url="^(.*)$" />
<action type="Rewrite" url="folder/{R:0}.cshtml" />
</rule>
</rules>
The first rule makes sure that all requests are to friendly URLs. The second takes the friendly URL and rewrites it to your physical path, where the physical path is folder/[FRIENDLY_PATH].cshtml.
I am redirecting a lot of old pages because of a new webdesign. However I have run into one little issue.
I want to redirect:
www.domainname.com/Default.aspx
But not redirect
www.domainname.com/somesub/Default.aspx
I need it written like this:
<rule name="301 Redirect Default">
<match url="???????" />
<action type="Redirect" url="http://www.domainname.com/index.php" redirectType="Permanent" />
</rule>
Where the questionmarks mark the regex I need.
Can anyone help?
Cheers
How about
<match url="^Default\.aspx" />
Also see e.g. this article regarding IIS rewrite rules.