Proper method to remove www from address using IIS URL Rewrite

If you want it to work with any hostname (not hardcoding it into the rule), you’d want to do something like this: <rule name=”Remove www” stopProcessing=”true”> <match url=”(.*)” ignoreCase=”true” /> <conditions logicalGrouping=”MatchAll”> <add input=”{HTTP_HOST}” pattern=”^www\.(.+)$” /> </conditions> <action type=”Redirect” url=”http://{C:1}/{R:0}” appendQueryString=”true” redirectType=”Permanent” /> </rule> in the redirect action, the {C:1} contains the second capturing group … Read more

IIS7 URL Rewrite – Add “www” prefix

To make it more generic you can use following URL Rewrite rule which working for any domain: <?xml version=”1.0″ encoding=”UTF-8″?> <configuration> <system.webServer> <rewrite> <rules> <rule name=”Add WWW” stopProcessing=”true”> <match url=”^(.*)$” /> <conditions> <add input=”{HTTP_HOST}” pattern=”^(?!www\.)(.*)$” /> </conditions> <action type=”Redirect” url=”http://www.{C:0}{PATH_INFO}” redirectType=”Permanent” /> </rule> </rules> </rewrite> </system.webServer>

IIS AAR – URL Rewrite for reverse proxy – how to send HTTP_HOST

This post has the answer – Modifying headers with IIS7 Application Request Routing Need to enable preserveHostHeader – can’t see how you do that in the UI but this works Run this from command line to update Machine/webroot/apphost config %windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/proxy -preserveHostHeader:true /commit:apphost

Set RewriteBase to the current folder path dynamically

Here is one way one can grab the RewriteBase in an environment variable which you can then use in your other rewrite rules: RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$ RewriteRule ^(.*)$ – [E=BASE:%1] Then you can use %{ENV:BASE} in your rules to denote RewriteBase, i.e.: #redirect in-existent files/calls to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteRule . %{ENV:BASE}/index.php [L] Explanation: … Read more

The Redirection of Multiple Parked Domains doesn’t Work with Filename [closed]

If the questioner starts rewrite ruling with [R=301] 301 redirect, a.k.a. “Permanently Redirect”, and then he try to view his URL www.parkeddomain1.com/subfolder/ but the result of the rule wasn’t what he want, then even he try to change the redirecting rule, his web browser will always redirect that URL into the first URL where it … Read more

Rewrite history git filter-branch create / split into submodules / subprojects

I resolved my own question, here is the solution: git-submodule-split library another_library Script git-submodule-split: #!/bin/bash set -eu if [ $# -eq 0 ] then echo “Usage: $0 submodules-to-split” fi export _tmp=$(mktemp -d) export _libs=”$@” for i in $_libs do mkdir -p $_tmp/$i done git filter-branch –commit-filter ‘ function gitCommit() { git add -A if [ … Read more

Apache rewrite rules not being applied for angularjs

This is now much easier in Apache 2.2.16+ using the FallbackResource directive. FallbackResource /app/index.html http://httpd.apache.org/docs/2.2/mod/mod_dir.html#fallbackresource Depending on how you’re forwarding access to your API you may need to also leverage the enclosure to disable the fallback resource on specifically on API requests (2.2.24+). <Directory /api> FallbackResource disabled </Directory>

Routes in Codeigniter – Automatically

The problem with your route is that by using :any you match, actually…ANY route, so you’re pretty much stuck there. I think you might have two solutions: 1)You can selectively re-route all your sites controller individually, like: $route[‘aboutus’] = “aboutus”; $route[‘where-we-are’] = “whereweare”; //And do this for all your site’s controllers //Finally: $route[‘(:any)’] = “polica/ogled/$1”; … Read more

Routing URLs in PHP

Use mod_rewrite to route everything to a single index.php file. Then check the variable in $_SERVER[‘REQUEST_URI’] within this file to dispatch to the required handler. This configuration will enable mod_rewrite, if it’s installed: DirectorySlash Off Options FollowSymLinks Indexes DirectoryIndex index.php RewriteEngine on RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ – [L] RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^.*$ – … Read more