Hi, I have a football website where matches URL looks something like these : http://www.footballalive.com/2595-Villarreal%20vs%20Twente%20%28Europa%20League%29%20Live%20Football%20Highlights.aspx Now, i want to change them into something like this http://www.footballalive.com/Highlights/2595/Villarreal%20vs%20Twente%20%28Europa%20League%29%20Live%20Football%20Highlights.aspx But as i am tryin the new URL, the css seems to go wrong. YOu can check by clicking on the links. Thanks
Hi, Thanks for reply Well, i am making the site in ASP .NEt using C# So in Global.asax file, i did the follow : protected void Application_BeginRequest(object sender, EventArgs e) { // If the requested file exists if (File.Exists(Request.PhysicalPath)) { // Do nothing here, just serve the file } // If the file does not exist then else if (!File.Exists(Request.PhysicalPath)) { // Get the URL requested by the user string sRequestedURL = Request.Path.Replace(".aspx", ""); // Highlights if(sRequestedURL.Contains("-")==true) { int n = Convert.ToInt32(sRequestedURL.IndexOf("-")); int m; for (int i = n; ; i--) { if (Convert.ToChar(sRequestedURL) == '/') { m = i; break; } } string sTargetURL = "~/VideoGallery.aspx?id=" + sRequestedURL.Substring(m + 1, n - m - 1); Context.RewritePath(sTargetURL, false); } //New Address if (sRequestedURL.IndexOf("/Highlights/") != -1) { int n = Convert.ToInt32(sRequestedURL.LastIndexOf("/")); int m; n--; for (int i = n; ; i--) { if (Convert.ToChar(sRequestedURL) == '/') { m = i; break; } } string sTargetURL = "~/VideoGallery1.aspx?id=" + sRequestedURL.Substring(m + 1, n - m); Context.RewritePath(sTargetURL, false); } // Owing to RewritePath, the user will see requested URL in the // address bar // The second argument should be false, to keep your references // to images, css files // ###### I M P O R T A N T ###### // To enable postback in ShowContents.aspx page you should have following // line in it's Page_Load() event. You will need to import System.IO. // Context.RewritePath(Path.GetFileName(Request.RawUrl), false); }
you need to put in the starting slash in the path to your css, favicon and js files in your html head. Right now it looks like: <link href="css/style.css" rel="stylesheet" type="text/css" /> And you need it to look like: <link href="/css/style.css" rel="stylesheet" type="text/css" /> See the starting slash that starts the href url? This will need to be done for all head links, the js files css files and favicons