Click to See Complete Forum and Search --> : 301 redirect...


afranklin
09-16-2011, 03:02 AM
Hi,

I am trying to redirect any invalid links on my site to the homepage. I have the following web.config file which redirects to /contact but I can't figure out what path to use to redirect to the homepage. I have tried the full url and variations- please can anyone help?:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Rewrite All" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/contact" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Thanks!

DriveHard_99
09-23-2011, 12:03 AM
In my opinion you would be better off with something like asapi rewrite by Hilicon. Basically gives you the ability to have an actual htaccess file on a microsoft server. I assume your running on a microsoft server correct?

If so code would look something like this:

RewriteBase /
RewriteRule ^monthlyspecials\.asp$ http://www.mydomain.com/monthlyspecials.asp [NC,R=301,L]

or as simple as

RewriteBase /
RewriteRule ^default\.htm$ / [R=301,L]

This one hear would simply rewrite the default .html to for example mydomain.com/ opposed to mydomain.com/default.htm

DriveHard_99
09-23-2011, 12:08 AM
If you don't mind me asking how many url's need to have the redirect? That could be very relevant to how its executed.

devnty06
09-28-2011, 02:19 AM
Take the old-page.asp that is being renamed or moved and remove all of the code. Place the below code in place of the old HTML/XHMTL.

<%@ Language=VBScript %>
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "/new-page.asp"
%>

In the above 301 redirect example, you need to change the Location to the URI of your new-page.asp. Include the full URI path unless you are redirecting to a root level page (index.asp, default.asp, etc.). If you are setting up a 301 redirect for a root level page, keep the URI short and without the index.asp file name. For example...

"Location", "/sub-directory/"

website development services | Web development company (http://www.***********.com/)

Arindam
09-30-2011, 09:19 PM
when i write the .htaccees rule in page url

e.g.
RewriteRule ^painting-(.*)/(.*)/(.*).html painting.php?u_category=$1&u_subcategory=$2&u_pg=$3

it shows

http://www.artauctionindia.com/painting/Art-Gallery/Landscape-Painting/1.html

its find out the directory but there is no Art-Gallery,Landscape-Painting directory in root server.

how can i redirect the page to http://www.artauctionindia.com/painting/Art-Gallery/Landscape-Painting/1.html