- February 8, 2017
- Posted by: iSummation Team
- Category: Uncategorized
Recently I was working with site migration from windows to ubuntu server. Normally everything goes smoother except case sensitivity of file name. While working with window we never take care about file name case since it doesn’t matter in window. Although we use standard for file naming but mistake will not reveal. After renaming file name accordingly everything work fine except one project. In this project I was running ColdBox framework in root folder for all kind of administrative work or business management and there was a folder /website which contain front public website. Front website running under MURA cms. When we move to RAILO and UBUNTU home page load correctly but rest of pages showing 404 error.
Since we were not using index.cfm in url required to make changes in .htaccess file to make sure URL correctly rewritten. Below is .htaccess code
1 |
<span class="typ" style="font-size: 14px; background-color: transparent; color: rgb(43, 145, 175);">Options</span><span class="pln" style="font-size: 14px; background-color: transparent;"> </span><span class="pun" style="font-size: 14px; background-color: transparent;">+</span><span class="typ" style="font-size: 14px; background-color: transparent; color: rgb(43, 145, 175);">FollowSymLinks</span><span class="pln" style="font-size: 14px; background-color: transparent;"></span><span class="typ" style="font-size: 14px; background-color: transparent; color: rgb(43, 145, 175);">RewriteEngine</span><span class="pln" style="font-size: 14px; background-color: transparent;"> </span><span class="typ" style="font-size: 14px; background-color: transparent; color: rgb(43, 145, 175);">On</span><span class="pln" style="font-size: 14px; background-color: transparent;"> </span><span class="typ" style="font-size: 14px; background-color: transparent; color: rgb(43, 145, 175);">DirectoryIndex</span><span class="pln" style="font-size: 14px; background-color: transparent;"> index</span><span class="pun" style="font-size: 14px; background-color: transparent;">.</span><span class="pln" style="font-size: 14px; background-color: transparent;">cfm</span><span class="typ" style="font-size: 14px; background-color: transparent; color: rgb(43, 145, 175);">RewriteRule</span><span class="pln" style="font-size: 14px; background-color: transparent;"> </span><span class="pun" style="font-size: 14px; background-color: transparent;">^</span><span class="pln" style="font-size: 14px; background-color: transparent;">$ </span><span class="pun" style="font-size: 14px; background-color: transparent;">/</span><span class="pln" style="font-size: 14px; background-color: transparent;">website</span><span class="pun" style="font-size: 14px; background-color: transparent;">/</span><span class="pln" style="font-size: 14px; background-color: transparent;"> </span><span class="pun" style="font-size: 14px; background-color: transparent;">[</span><span class="pln" style="font-size: 14px; background-color: transparent;">R</span><span class="pun" style="font-size: 14px; background-color: transparent;">]</span><span class="pln" style="font-size: 14px; background-color: transparent;"></span><span class="typ" style="font-size: 14px; background-color: transparent; color: rgb(43, 145, 175);">RewriteCond</span><span class="pln" style="font-size: 14px; background-color: transparent;"> </span><span class="pun" style="font-size: 14px; background-color: transparent;">%{</span><span class="pln" style="font-size: 14px; background-color: transparent;">DOCUMENT_ROOT</span><span class="pun" style="font-size: 14px; background-color: transparent;">}%{</span><span class="pln" style="font-size: 14px; background-color: transparent;">REQUEST_URI</span><span class="pun" style="font-size: 14px; background-color: transparent;">}</span><span class="pln" style="font-size: 14px; background-color: transparent;"> </span><span class="pun" style="font-size: 14px; background-color: transparent;">!-</span><span class="pln" style="font-size: 14px; background-color: transparent;">d</span><span class="typ" style="font-size: 14px; background-color: transparent; color: rgb(43, 145, 175);">RewriteRule</span><span class="pln" style="font-size: 14px; background-color: transparent;"> </span><span class="pun" style="font-size: 14px; background-color: transparent;">^</span><span class="pln" style="font-size: 14px; background-color: transparent;">website</span><span class="pun" style="font-size: 14px; background-color: transparent;">/([</span><span class="pln" style="font-size: 14px; background-color: transparent;">a</span><span class="pun" style="font-size: 14px; background-color: transparent;">-</span><span class="pln" style="font-size: 14px; background-color: transparent;">zA</span><span class="pun" style="font-size: 14px; background-color: transparent;">-</span><span class="pln" style="font-size: 14px; background-color: transparent;">Z0</span><span class="pun" style="font-size: 14px; background-color: transparent;">-</span><span class="lit" style="font-size: 14px; background-color: transparent; color: rgb(128, 0, 0);">9</span><span class="pun" style="font-size: 14px; background-color: transparent;">/-</span><span class="pln" style="font-size: 14px; background-color: transparent;">\s</span><span class="pun" style="font-size: 14px; background-color: transparent;">]+)</span><span class="pln" style="font-size: 14px; background-color: transparent;">$ </span><span class="pun" style="font-size: 14px; background-color: transparent;">/</span><span class="pln" style="font-size: 14px; background-color: transparent;">website</span><span class="pun" style="font-size: 14px; background-color: transparent;">/</span><span class="pln" style="font-size: 14px; background-color: transparent;">index</span><span class="pun" style="font-size: 14px; background-color: transparent;">.</span><span class="pln" style="font-size: 14px; background-color: transparent;">cfm</span><span class="pun" style="font-size: 14px; background-color: transparent;">/</span><span class="pln" style="font-size: 14px; background-color: transparent;">$1 </span><span class="pun" style="font-size: 14px; background-color: transparent;">[</span><span class="pln" style="font-size: 14px; background-color: transparent;">PT</span><span class="pun" style="font-size: 14px; background-color: transparent;">]</span> |
Added "website/" in last rule to make sure rule only apply for request starting with website and rest of part will be consider as URL parameter for MURA to handle it. Anyhow there were two index.cfm added in URL after rewrite rule executed.
Let’s say URL I am trying to access is
http://example.com/website/privacy/
is received as below in MURA
http://example.com/website/index.cfm/privacy/index.cfm
Notice two index.cfm inside URL and this was causing 404 error since Apache/Tomcat looking for index.cfm under privacy folder which doesn’t actually exists. I was not able to find what actually adding index.cfm at end. I am sure that RewriteRule was correct and creating correct URL. After googling it turn out that TOMCAT (yes TOMCAT) was adding index.cfm at the end. Since by default Tomcat allowing SES mapping from root of the web application only you required to add new <url-pattern> in web.xml file.
RESOLUTION:
Search for comment Basic SES Mapping in web.xml file and add <url-pattern>/website/index.cfm/*</url-pattern>. Now it should allow you to SES mapping from website folder as well.
Hope this help.