• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

*solved* make domain.com/index.aspx show as domain.com

Mucman

Diamond Member
index.aspx is the default of the website. So when http://domain.com/ is requested it loads the index.aspx file but does not display it in the browsers address bar. My boss wants it so that when people click on a link that has http://domain.com/index.aspx, they also see the URL http://domain.com/.

URLRewriting seems to do the opposite of what I want. I looked at the function:

void HttpContext.RewritePath(string path)

in ASP.NET but it doesn't do what I want. I am now thinking that an ISAPI module will need to be installed. Or am I completely wrong and that this is a browser issue? Or should I remove the default page and create a Rewrite rule for the "/" url so that it processes some.aspx, and have the index.aspx page simply do a 302 redirection to the "/" url?

 
Maybe the thing to do is enclose the whole site inside a frame in the main index page. Not the best option, since now nobody will be able to bookmark individual pages, but it will do what your boss wants.

I'm not sure if IIS has the same URL rewriting options that Apache does. Most likely it doesn't...

You could also look into doing something with JavaScript I suppose. Not sure if it'll help much though.
 

It is the browser that puts the index.aspx in the URL address bar, not the server. What you can try is redirecting them to www.domain.com/ if they request www.domain.com/index.aspx

'this isn't tested, only from memory
If Request.Url.AbsolutePath = "index.aspx" Then
Response.Redirect("www.domain.com/", true)
ENd If
 
Cheetah8799, frames are definitely not going to be implemented. ASP.NET can support similar rewrite options that Apache does but it requires a seperate Rewrite Engine to be added to the website (which is trivial enough), but it doesn't handle the situation that I am describing unfortunately. My bosses rationale for this is to increase our google rankings. I have no idea if it matters, but he signs my pay cheques so I do as he asks. 🙂

KB, I tried that but it results in an infinite redirect loop.

Here's what I got going so far:

Default doc = default.aspx
index.aspx does not exist
My global.asax is attached

A request to http://domain/index.asp shows up as http:/domain/ and it displays the correct content. Of course if someone requests default.aspx we are in the same boat again. Also, changing the default doc might change other directories of our website so I would have to make the global.asax smarter to handle this.

Any other ideas?
 
Ok, I have managed to get it to work while imposing the least amount of changes to our code and file structure.

I changed the websites default doc order to be : default.aspx, index.aspx. I used the code in my previous post to catch any requests for /index.aspx, and do a 301 redirect to the "/" path. I removed index.aspx from the root path and renamed it default.aspx. All of our other directories work fine since they do not have default.aspx files so the index.aspx file is still returned as the default document.

Of course now if someone is to request /default.aspx the problem still exists... Since there are absolutely no references to default.aspx anywhere on our website, search engines should never directly link to it. So it's not 100% the correct solution, but it does solve the problem with other people linking to the /index.aspx page.
 
Back
Top