Forum Moderators: phranque

Message Too Old, No Replies

From asp to php

Redirect problems related to moving an asp siet to a php driven site

         

whtwtr

12:51 pm on Oct 24, 2010 (gmt 0)

10+ Year Member



Greetings everyone,

I am having some difficulty redirecting some old "asp based" url's to my new site that is now based on php.

Example,
http://mydomain/en/home.asp


should redirect to:

http://mydomain.com


My rule:
ReWriteRule ^en/home\.asp$ / [R=301,L]

problem is My rules work just fine in my development environment but when it comes to testing on the production server the rules don't seem to work and I receive a 404 page similar to:

HTTP Error 404 - File or directory not found.
Internet Information Services (IIS)


I have verified that my production server is a Linux /Apache based sever and not an IIS one. In addition I have disabled everything related to ASP in the server config.

I must be missing something really trivial, because I can't find anything related to this problem on a Google search..

Has anyone else experienced this behavior? ~Thanks in advance..

jdMorgan

2:26 pm on Oct 24, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Two points:

First, it's good to hear that your redirect failed, because redirecting is not required and may in fact harm your site's ranking for several months -- something that many businesses can ill-afford these days.

Second, if your server is returning an IIS error message, then it's likely an IIS server and not Apache. Either the host gave you another IIS server, or your DNS is still pointing to an 'old' IIS server somewhere.

You may want to check to see how the server identifies itself using the "Live HTTP Headers" add-on for Firefox and Mozilla-based browsers or a similar tool to inspect the actual server's HTTP response headers and see what kind of server it says it is.

Back to the first point... Unless you want to go through the pain of having to wait (days/weeks/months/quarters) while your entire site is re-indexed, consider the option of simply serving .php-generated pages when .asp URLs are requested. This can be accomplished with one mod_rewrite rule implementing the URL-to-internal-filepath rewrite, one AddHandler directive, and one AddType directive. The RewriteRule would look like this:

RewriteRule ^(.+)\.asp$ /$1.php [L]

This is a URL-to-internal-filepath rewrite, as opposed to an external URL-to-URL client redirect. This rule just says, "When we get a request for a .asp URL, invoke a same-named .php file." Note that URLs and filepaths are entirely-different things for use in two different address-spaces ("out on the Web" vs. "here inside the server"), and that they are related only by the action of a server.

The idea is to accept a request for a .asp URL, and then serve content using a .php script. With this method, none of your URLs need to be changed, and search engines will see no difference.

There's one more issue here, and that is the question of where you are putting your code. Be aware that the RewriteRule pattern will likely need to change depending on whether you put the code in a .htaccess file, in a server config file inside a <Directory> section, or in a server config file outside any <Directory> section.

Also note that the syntax for a trouble-free redirect rewriterule is

RewriteRule ^en/home\.asp$ http://www.example.com/ [R=301,L]

By specifying a protocol and hostname, you can avoid some common difficulties.

Anyway, consider the problem of redirects discarding the search engines' entire index of your site, check your server headers to re-verify that you're on an Apache server, and then let us know where you're putting this code and what you want to do with it.

Jim