Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am in the process of moving a site made up of asp pages to a completely redesigned Wordpress site. It has come time to create the 301 redirects for those old pages, so I don't break any links that are out there.

I do have the redirection plugin installed as well.

I've tried using it to do these types of redirects. I've also tried using htaccess, but everything I've tried results in getting this error.

404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

It's my guess that the server is trying to process the page before applying the redirect.

I'm sure others have done this before, so any thoughts/ideas would be greatly appreciated.

Thanks,

Jeremy

My htaccess currently looks like this:
FileETag None
Header unset ETag
Options +FollowSymLinks

Redirect 301 /customers/default.asp http://twostep2.com/customers/testimonials

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# BEGIN WordPress

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

share|improve this question
    
Do you have mod_rewrite enabled? Are pretty permalinks working on your regular WP pages and posts? –  MathSmath Jan 7 '11 at 22:32
    
Math, yes mod_rewrite is enabled and pretty permalinks work. –  jeremyswright Jan 7 '11 at 23:00
    
Weird, because it looks like you're getting an Apache/IIS 404, not a Wordpress-delivered 404. Which suggests that Wordpress isn't processing the request at all...the server is returning a 404 before WP has a chance to. You're trying to redirect between pages on the same domain, right (like you're not trying to go from domain1.com/something to domain2.com.something)? In general, some more detail in the question would help. Maybe provide a link to the site, and an example of the htaccess rules you tried. –  MathSmath Jan 7 '11 at 23:43
    
Added my htaccess to my original question. –  jeremyswright Jan 8 '11 at 0:03
    
Redirect is enabled by mod_alias, not mod_rewrite. That may be the problem. check if you have mod_alias enabled, if not, use a RewriteRule, which is enabled by mod_rewrite. –  Cronco Jan 8 '11 at 4:20
show 1 more comment

2 Answers

Hi @jeremyswright:

Using Apache directives is definitely the well-known way to handle redirects. But I'm going to recommend another, easier-to-debug approach; just write your 301 Redirects in PHP using the 'template_redirect' hook provided by WordPress. The following question title links to my answer where I provide full code for solving your problem:

Just code your 301 redirects as either PHP if or select..case logic, or by using the old URL as an array key and the new URL as an array value. Performance shouldn't be a concern because search engines will quickly adjust to the serve the new URLs and any traffic you might be receiving on the old URLs will quickly diminish.

And be sure to put your WordPress site back into its standard state of the:

# BEGIN WordPress

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

# END WordPress
share|improve this answer
    
Mike, I will give that a try. I think part of the issue is that the server is trying to process the ASP page before Wordpress gets involved. For example, if you go here, you will see the 404 error I receive: twostep2.com/customers/default.asp. Any thoughts? –  jeremyswright Jan 8 '11 at 21:22
    
@jeremyswright - I potentially agree with your analysis. Have you switched to the WordPress standard .htaccess file I presented yet? If yes, where is your WordPress install located? In the root? In the /customers/ directory? If you (temporarily) modify index.php to echo 'Hello'; then exit; does it print "Hello?" –  MikeSchinkel Jan 8 '11 at 23:15
    
@jeremyswright - I just looked, really nice looking site. Do you have a /customers/ directory with it's own .htaccess file? This URL twostep2.com/customers implies you do. Maybe that's it? Also, would you mind contacting me directly as there are a two ideas I'd like to discuss with you now that I've seen your work and your client's site. –  MikeSchinkel Jan 8 '11 at 23:37
    
Thanks Mike. I'll contact you. On twostep2.com/customers, I have that directory setup to redirect based on the code you provided. There actually isn't a directory there, so it is redirecting completely based on your code. –  jeremyswright Jan 10 '11 at 13:47
    
@jeremyswright - Is your issue resolved yet? –  MikeSchinkel Jan 10 '11 at 17:04
show 1 more comment
up vote 0 down vote accepted

In case anyone else stumbles upon this, the issue had to do with a setting in my provider. All of the comments above were correct on how to do redirects, but the problem was on the server side.

I am using Rackspace cloud sites to host the wordpress site.

In order to have ASP or ASPX pages redirect to PHP, you have to enable IIS on the apache server.

they provide instructions here: http://cloudsites.rackspacecloud.com/index.php/How_do_I_enable_a_secondary_technology%3F

You then have to have a web.config file to do the redirect from ASP to PHP.

Jeremy

share|improve this answer
    
Glad you got this sorted! Please accept your own answer (with the green checkmark) so this question is resolved. –  MathSmath Jan 12 '11 at 22:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.