Translating URL in .htaccess - url

Here's what I would like to do
Say I have a domain, www.mydomain.com
I have my coldfusion application in www.mydomain.com/myapp
There is a folder under myapp called x and under x is y
like this
wwwroot - myapp - x - y - index.cfm
So y's URL will be
www.mydomain.com/myapp/x/y
I want the users to type
http://www.mydomain.com/y
Then I want to translate that URL to
http://www.mydomain.com/myapp/?virtualFolder=y
But throughout the session I want the users to only see the original URL
Would you be able to tell me how I could achieve this, may be in .htaccess?
[IIS webserver, Coldfusion 10, shared hosting]
Thanks

you cant use .htaccess in iis its Apache only, iis (depending on the version) has a isapi plugin that can help you there, but if you are on shared hosting you probably wont have access it. You also wont be able to use the Application.cfc OnMissingTemplate method because generally only direct requests for .cfm[l] or .cfc pages are sent to ColdFusion to be processed.
The only way that I see you being able to accomplish what you want is to use the index.cfm to do your own redirecting.
so instead of
http://www.mydomain.com/y
you will have to do
http://www.mydomain.com/index.cfm/y
in your index.cfm file you will then parse the url parameter and and using cflocation with status code of 301 to redirect to the actual page.

Related

URL Routes In IIS7 MVC 5 (Single Paged Application)

After publishing a MVC5 web application of mine to my IIS server (Individual User Accounts), it would seem that the URL is accessed incorrectly.
During debug, it would be e.g http://localhost:1234/api/Account/UserInfo?=XXXXX
The debug works just fine. The only issue kicks in after I've published it via my IIS7 server.
After publishing and using Google Chrome's console, it would appear that the page is requesting for a resource at mydomainname.com/api/Account/UserInfo?=XXXX instead of mydomainname.com/WEBAPPLICATIONNAME/api/Account/UserInfo?=XXXX.
My best guess is to modify the URLs in /Scripts/app/app.datamodel.js but it would just cause more parsing problems.
I've searched around and can't seem to find any related problems. I hope someone here will be able to lend a hand.
Look like you are using relative path like "/api/Account/UserInfo". Instead i'll recommend you to use #Url.Content("/api/Account/UserInfo"). This will solve your problem
Explanation
In local system when we run application in WebDev server it never have sub folder (like WEBAPPLICATIONNAME) therefore you relative path work correctly. but when you host your application in IIS under Default website in another new website /Virtual folder (like 'WEBAPPLICATIONNAME') then "/api/Account/UserInfo" fall back to Default Website because for '/' in starting. #Url.Content or #Url.Action make sure to add virtual directory name, hence changing your path to "/WEBAPPLICATIONNAME/api/Account/UserInfo" in IIS.

IIS 6 .NET MVC web app deployment - need to achieve a specific URL structure

I need my local (testing) deployment to respond to a URL like
http://localhost/apps.mydomain.com/myappname
not
http://localhost/myappname
Long story as to why but I just need that to be the case.
I actually had this working for awhile but I can't remember how. I had to delete and add the site again and now can't figure out what combination of settings gave me the result.
How can I achieve that URL structure locally?
MORE INFO: I've created a website called "apps.mydomain.com". I then added an application under that site with the alias "myappname". This app can be invoked with URL
http://localhost/myappname
Why? What happened to "apps.mydomain.com"? When I add it...
http://localhost/apps.mydomain.com/myappname
I get a 404.
You can just create directories apps.mydomain.com and apps.mydomain.com\myappname under C:\inetpub\wwwroot.
Or, if you don't want to publish your application in wwwroot, you can create virtual directory in IIS.

ASP.NET MVC server path is different from application path

I have an unusual circumstance where our web server inserts a folder into the url path before loading the page. Let me give you an example:
The app is called equipment and if I were to run it on a normal server setup, it would look like:
www.site.com\equipment\home\index
BUT when I run it on our server, it inserts "idn" in the url:
www.site.com\idn\equipment\home\index
The messes up my relative references. The MVC functions want to redirect to use "\equipment\" instead of "\idn\equipment\". This happens with Scripts.Render(), Return View(), etc.
Also, I can't hardcode the "idn" into my urls b/c then it is no longer relative and it won't work on my dev box or test servers b/c they don't have a "idn" subfolder in localhost.
I also tried functions such as Request.ApplicationPath and what not but none of them return the "idn" in the result.
Is there way to MVC to know that this "idn" was inserted into the url and account for it?
Thanks!
Create your application on the test/production server in the idn folder, then it all works.

Joomla Site URL

I have a website on a 1and1 server. I have 2 domains on the package; the default url somenumbers.websitehome.co.uk and my actual URL.
The problem is, Joomla quotes the somoenumbers.websitehome.co.uk in system e-mails instead of my actual URL. They both point to the same directory I just don't want to give a stupid URL to my users.
I think I have narrowed it down to the $siteUrl variable but I'm not sure how to go from here.
Thanks
James
At first I thought this sounded largely like a DNS issue - but then you said you only have 1 Joomla installation and both domains point to that directory.
If they're both pointing to the same directory, then both domains will display the same Joomla installation. That is, unless you're checking to see where they are coming from and having the content display dynamically based upon how they got to your site - but from your comments I doubt you're doing that. How your domains are behaving is the expected response if you're pointing them both to the same directory.
If you want 2 sites on the same hosting? Setup 2 databases (or apply different prefix for each site and use 1 database) and set up each website in it's own directory.
Adjust the DNS of each domain name (and subdomain name) to point the appropriate directory.
From there, use the .htaccess file and SEF URL's to get rid of any indicator of the directory so that it displays the same as if the site was in the root directory.
That is the best way to accomplish what you're after - because from the sounds of it Joomla is doing exactly as it should, displaying correctly what is in the directory since both domain names point to the same directory.
$siteUrl should be left blank.

iis 7 url rewrite with preset paths

I'm trying to make something like this work in iis 7, or web config
request:
products.aspx?id=100
rewrite:
domain/products/mp3
Please note, I do not want redirection, for domain/products/mp3 is invalid path, I just want the url rewrite so the user sees this path but the server serves the actual request.
Can you help?
Can you use the URL Rewrite functionality from ASP.NET instead? That was built for that.
RouteTable.Routes.MapPageRoute("Test", "domain/products/{type}", "~/products.aspx");
Then in products.aspx you have to map from mp3 to 100 somehow, but I assume you have a db table for that anyway.

Resources