How To Rewrite .aspx To .html Or .php With Htaccess

Mar 31, 2011

I'm trying to rewrite some URLs that have a .aspx extension to .html. I looked around and saw that you can put something like

RewriteEngine On
RewriteCond %{QUERY_STRING} ^file=(.+)$
RewriteRule ^(.+).aspx$ $1.php?f=%1

in the htaccess to rewrite any .aspx to .php. However, when I put that in the .htaccess file, it doesn't seem to work for me. mod_rewrite is enabled and the site is on a Linux server so those are not the issue. If I try to go anywhere with a .aspx extension, I get a "Server Error in '/' Application." error.

You can see this by going here [URL]

View 2 Replies


Similar Messages:

How To Correctly Rewrite URL With .aspx To URL Without .aspx

Oct 6, 2010

I have a site that currently uses the .aspx extension on its pages. It's getting a Joomla conversion and the .aspx extension will not work anymore. I need it so that if someone enters the .aspx extension, it will just get removed the URL so none of the SEO on the current site breaks.

For example, I need [URL] to be rewritten/redirected to [URL]

This is what I have in my web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Migrate to PHP">
<match url="^([_0-9a-z-]+).aspx" />
<action type="Redirect" redirectType="Permanent" url="{R:1}" />
</rule>
<rule name="Rewrite .aspx">
<match url="^([_0-9a-z-]+)/?([_0-9a-z-]+).aspx" />
<action type="Redirect" redirectType="Permanent" url="{R:1}/{R:2}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>


The first URL match is for any URLs that have a URL like services.aspx instead of services/managed-services.aspx

Whenever I go to [URL] it gives me an internal server error, but [URL] rewrites correctly. What can I do to fix this?

View 2 Replies

C# - Url Rewrite For Aspx Page?

May 7, 2010

I have a page, called foo.aspx and i d like to rewrite the url as bar.somethingHow to do this? How does url rewrite happens in asp.netShould i create a generic handler?or should i get some url rewrite modules and add to app?

View 3 Replies

Iis7 Url Rewrite Module With Html?

Feb 19, 2010

Is it possible to use iis7 url rewrite module for html pages?

Like this:

http://www.site.com/index.html?x=newfolder =>
http://www.site.com/newfolder

View 2 Replies

HTML - Why Does Rewrite Relative Paths For Runat=server Anchor Controls

Mar 24, 2010

I have my UserControls in a ~/Controls folder in my solution:

/Controls/TheControl.ascx

If specify the following:

<a id="theId" runat="server" href="./?pg=1">link text</a>

ASP.Net seems to want to rewrite the path to point to the absolute location. For example, If the control is on [URL] the link href will be rewritten to read

<a id="munged_theId" href="../../Controls/?pg=1>link text</a>

Why does Asp.Net rewrite these control paths, and is there an elegant way to fix it?

I just want the anchor control to spit out exactly what I tell it to!!! Is that so hard?

EDIT:

I've basically done what Kelsey suggested. I knew I could do it this way, but I don't like adding markup in my code when I want something relatively simple. At least it solves the problem:

Aspx page:

<asp:PlaceHolder ID="ph" runat="server"></asp:PlaceHolder>

Code-behind:

var anchor = new HtmlGenericControl("a") { InnerText = "Previous" + " " + PageSize) };
anchor.Attributes["href"] = "?pg=" + (CurrentPage - 1);
anchor.Attributes["class"] = "prev button";
ph.Controls.Clear();
ph.Controls.Add(anchor);

As you can see by the amount of code needed for what is essentially supposed to be be a simple and light-weight anchor, it's not the most optimal solution. I know I could use a Literal but I figured this was cleaner as I'm adding more than one anchor.

View 4 Replies

Php - Translating .htaccess To Web.config?

Dec 1, 2010

I am hosting a php application on my virtual Windows server running IIS.

The person who wrote the php website for me asked me to put this piece of codes in a .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

But as this application is running on IIS, I need to translate this piece of codes to web.config. So could any one have experience about this, translate them into web.config?

View 1 Replies

Vb.net - How To Load Webpages Faster Using .htaccess..

Mar 21, 2011

How to load asp.net webpages faster using .htaccess..

what was the coding for .htaccess so that the webpages loads faster ..i have hosted my site on .ixwebhosting.

View 1 Replies

How To Access .htaccess File In Windows Server

Aug 12, 2010

I am try to implement URL re-write functionality using Helicon Manager for my ASP.net application running on windows server. I also generate a .htaccess file and place in a root directory, but badly my application failed to access this file and not performing the URL re-write. Here I want to know how can i access .htaccess file through which we can perform a successful URL re-write implementation.

View 1 Replies

Php - 500 Internal Server Error For Addtype In Htaccess?

Aug 12, 2010

In reference to the accepted answer in http://stackoverflow.com/questions/3464141/php-website-to-aspx-net-website. Creating a new post since that post was over-loaded with comments.

htaccess file
AddType application/x-httpd-php .aspx
AllowOverride AuthConfig in apache config file.
trying to parse php in the aspx page.
index.html / index. aspx
This is the index file. OK!
<?echo "PHP working";?>

View 1 Replies

Configuration :: Redirect To Root (convert Htaccess Code To Web.config)?

Apr 28, 2010

I need convert my htaccess code to web.config code.

this is the htaccess code:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /index.php HTTP/
RewriteRule ^index.php$ http://www.wonderstarter.com/ [R=301,L]

View 2 Replies

Forms Data Controls :: Get Html Control Of .aspx Page In .aspx.cs Control?

Aug 12, 2010

.aspx:

<input type="file" id="file1" name="file1"/>

now i want to call the file control in .aspx.vb page. how can we call this..

View 3 Replies

HTML Act Differently In Aspx And Html?

Aug 28, 2010

i want to put the text in the vertical middle of the <td>

it works fine in .html page but if i use it in .aspx, then it goes to the top of the <td>

This is the script i use

<table
border="1px">
<tr>
<td
style="height:
100px"
valign="middle">

This should be in the middle

</td>
</tr>
</table>

is there any way to put the text in the vertical middle of the <td>??

View 9 Replies

Web Forms :: How To Write Aspx Page HTML From Aspx.cs Page On Page Load

Dec 1, 2010

i want to write aspx page html from aspx.cs page on page load..

i hav already used div.innerHtml...

i want to write below code in aspx page from aspx.cs page

[code]....

View 5 Replies

C# - Add HTML Id's To Tags In .aspx File?

Dec 28, 2010

So I'm writing an app that lets the user select a folder, it gets all the .aspx files in that folder, and lets the users check off which ones they want to add HTML ID's to.

Then they click start, and this runs

private void btnStart_Click(object sender, EventArgs e)
{
for (int i = 0; i < listFiles.CheckedItems.Count; i++)
{
}
}

It loops through all the selected file names. How do I open each of these .aspx files in the background, and go through them and add the id="thisItemId"

View 2 Replies

Remove HTML Or ASPX Extension?

Dec 19, 2010

In a hosted IIS7 environment, I am looking for the simplest way to use extension-less file names. Simply I have the following pages:

index.html (or .aspx) --> domain.com
gallery.html --> domain.com/gallery
videos.html --> domain.com/videos
etc...

I only have a handful of pages, I have no dynamic code, nothing special. All the examples I have found or methods I use in other sites I've developed revolve around dynamic content, pages, etc. I am simply looking for the simplest solution, ideally not requiring any sort of url rewrite module installed. Preferably, I could keep the .html extension instead of converting the site to a ASP.NET project, but that is an option.

View 3 Replies

Having Tool For HTML To ASPX Conversion?

Mar 4, 2010

I am a .net developer and I am in search of a tool that can convert HTML pages to ASPX pages?So, can you suggest me such tool? Does anyone having an idea for such conversion?

View 1 Replies

Conversion Of Html Pages To .aspx Using C#?

May 14, 2010

i m facing problem in converting .html pages to .aspx using c#secnario isi got one index.html pagei have to convert index.html into .aspx pages and that to in four pastop part as a.aspxmiddle part as b.aspxbottom part as c.aspxand then in d.aspx i have to combine all the three parts and call them in d.aspx...

View 7 Replies

Get HTML Linking In Aspx Page?

Feb 5, 2010

This might sound like a stupid question, but here is what I want:in an aspx page in Sharepoint wiki, there's a section that I can insert rich text and html code. Here I want to transfer plain html pages to sharepoint wiki.The original html page has many in-page links, like "/Build_Environment/SQL/macs.html#CREATE_TABLE" where links to a section called "Create_Table" in the same page.How would this be done in aspx page? Is it something can be rewritten in html format so that in aspx page, the html section will also work as before?

View 1 Replies

.net - Saving Aspx Page To Html?

Aug 10, 2010

while saving my aspx page as webpage(.htm)i did not get the values assigned to labels/textbox. i got oly the label. eg: customer name: xxxx

in the saved file(.html) i got oly customer name: and not the values when i store as .html. why?

View 1 Replies

Create A HTML Page From Aspx.cs?

Jun 24, 2010

I am trying to open a new HTML page(like pop up window) with data(I will get this data from database) when the user submits an order. I am using VS2008.

Does writing the Html code to a string and then use Response.Write will work correctly for opening the html as a pop up window? Is there any other better way to perform this action?

View 8 Replies

Only Capture Aspx Text Not Html Rendered

Dec 11, 2010

I try to send an email with the html generated from an aspx file. But having this problem that only capture the aspx text not the html rendered by aspx. how can i do it , must use htmltextwriter? This is the code sample

<%@ Import Namespace="System.IO" %>
<!--#include virtual="/asp/enviamail.aspx"-->
<%
Dim FILENAME as String = Server.MapPath("/boffice/adcasas.aspx")
Dim sw As StreamWriter
'Get a StreamReader class that can be used to read the file
Dim objStreamReader as StreamReader
objStreamReader = File.OpenText(FILENAME)
Dim contents as String = objStreamReader.ReadToEnd()
dim strBody
strBody = "<html>"
strBody = strBody & "<head></head>"
strBody = strBody & "<body>"
strBody = strBody & Chr(13) & "A sua prereserva foi suplantada"
strBody = strBody & Chr(13) & "Obrigado.Esperamos que o nosso serviço vá de encontro ás suas expectativas."
strBody = strBody & "</body>"
strBody = strBody & "</html>"
dim sformat="MailFormat.Html"..........

View 2 Replies

Web Forms :: Embedding Html In Aspx Page?

Dec 23, 2010

Right now i am creating .html page dynamically and including in iframe of aspx page. it works fine ,but when i deploy it.on using https://I am getting errors in IE8 .. It works fine with IE7 and Firefox,so instead of giving the html file as source to iframe.., i want to try showing the html directly on aspx page.. rather than giving as a file..

Below is my code..

</fieldset>
<iframe id="abc" runat="server" height="650" width="800" align="middle"
frameborder="3" scrolling="no" style="border: medium double #808080"
enableviewstate="False"></iframe>
abc.Attributes("src") = "/PDFs/" & rndFileName & "_First.html"

View 3 Replies

Finding Tool For HTML To ASPX Conversion?

Mar 4, 2010

I am a dotnet developer and I am in search of a tool that can convert HTML pages to ASPX pages?

So, can you suggest me such tool? Does anyone having an idea for such conversion?

View 2 Replies

Web Forms :: How To Convert From HTML In Aspx Form

Oct 20, 2010

This code works only in HTML format. This means that I can not select standard components: "Inserting an ASP.NET control will convert the HTML form in the page to an ASP.NET form and remove its current properties. Do you want to insert the ASP.NET control?"

When converted following code does not work anymore. I'd like that code works in ASP.NET mode.

[Code]....

View 3 Replies

How To Redirect Index.html#/abc/ To Newpage.aspx

Dec 24, 2010

I have a problem with trying to make some redirections from an old HTML page which was reading some parameters from the URL to feed some flash components to a new ASPX page.

The issue is that the page URLs are of the form: [URL] and that needs to redirect to something like: [URL]

There are several different values following the # but in essence they are all the same html page. Other problem is that the values are not even passed in a query string.

I'm using Windows Server 2008, IIS 7 (not R2) and I have installed the URL Rewrite module but so far my rules have not worked.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved