Forum Moderators: open
I have a website on a IIS 5.0 server. Currently, my website in accessible via both http ://www.mysite.com and http ://mysite.com. Good.
But the thing is when I hit http ://example.com the url remains the same in the address bar and I want it to be redirected to http ://www.example.com via a 301 permanent redirection (as for [google.com)...]
How can I do that? I have access to all the settings so I can do whatever I want on the server (although I don't know much about IIS, I'm more familiar with Apache...)
thanks to those who can answer me.
cheers
effisk
[edited by: Xoc at 12:32 am (utc) on Oct. 27, 2005]
If you can't do that, and if your pages are all ASP or ASPX, then you could put the redirect logic into a separate file and include that at the top of all of your ASP/ASPX files.
Barring either of those, you may be able to find an ISAPI component that will do this for you.
In IIS 5.0 and 6.0, ISAPI is the vehicle for preprocessing hits on a global scale. If you don't use ISAPI, then you need to do it with code in the requested file. That can be via an include. However, without ISAPI, the requested file still needs to be something other than a static .htm/.html file.
Sorry i have no answer for ur question but i think u know answer of my problem :)..
I am also facing same problem but i have linux hosting with apache server. When i open my site using "http://www.compose.co.in" it's not opening but when i use "http://compose.co.in" it's oppening site. can u tell why this problem is occuring and what is the solution of it.
Thanx.
Vineet,
We have only .aspx pages.
Since everything is in aspx pages, and using the IIS global method is not working, then the next alternatives are:
- Add the redirect logic via an INCLUDE file in the .aspx pages, or
- Add the redirect logic via inheritence in the .aspx.vb files, or
- Put the redirect logic into a globally available function and then call it from the Page_Load function in the .aspx.vb files.
Option 2 means you create your own base page class. This class inherits from "System.Web.UI.Page". Then change all of your other .aspx.vb files to inherit from your base class. Visual Studio hates this though, and you will always get an erroneous "Type Abstract" error when you open the associated .aspx files.
There may be a way of doing it with the web.config file, but I am not aware of it. If anyone knows the answer to this, please chime in.
"Redirect permanent / http://www.example.co.in/"
But after uploading it when i use example.co.in it is taking more then 2 minute time. and after 2 minutes it open "www.example.co.in".
before this altyeration opening time was 15 seconds.
Can any body tell me what is wrong with it. am i using wrong code?
[edited by: tedster at 6:20 am (utc) on Jan. 15, 2007]
[edit reason] use example.co.in [/edit]
IIS: Redirect a domain such as example.com to www.example.com [xoc.net]
But i am not on Windows server i am on linux server using Apache.
My reply was for the topic starter effisk.
For mod_rewrite, this should provide the answers you are looking for...
An Introduction to Redirecting URLs on an Apache Server [webmasterworld.com]
This does not work properly as I explained before. I lose the #anchors with this redirection.
You are going to need a program like ISAPI_Rewrite to further refine your URI Rewriting capabilities.
P.S. I believe .NET offers some additional rewriting features. I've not used them since we have ISAPI_Rewrite installed and I can drop a rewrite rule in the .ini file within seconds.
RewriteRule /sub/file1.asp#anchor http://www.example.edu/sub/file2.asp#anchor [I,O,RP,L]