Forum Moderators: phranque

Message Too Old, No Replies

Redirect the links I forgot to specify

         

cbetter

12:18 am on Jul 15, 2009 (gmt 0)

10+ Year Member



Forgive me if this covers ground already discussed, but I have searched this site and others and can't seem to find the exact solution to my problem.

I just moved my site to Wordpress. The URL structures between the old and new sites vary greatly, so I implemented a ton of 301 redirects in my .htaccess file.

The final thing I'd like to do is implement a "catch all" redirect for any links that I may have missed.

I'm not looking to do anything fancy with sub-folders and such (like in the other posts I've read). I'd just like the traffic to be redirected to my homepage.

For example, if someone goes to [mysite.com...]

...they will be redirected to [mysite.com...]

Obviously, I don't want to screw up the page-specific redirects already in place.

Thanks in advance for any help you can provide.

My current .htaccess file looks like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# BEGIN WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

***A bunch of 301 redirects here***

jdMorgan

12:33 am on Jul 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



All requests for URLs which do not resolve to existing files or directories will be rewritten to WordPress by that code (which is the 'standard' WordPress-provided code). So you cannot do what you are asking to do without removing the WordPress code (and killing WordPress).

Note also that your external redirect directives should precede your internal rewrites unless they are completely mutually-exclusive.

Jim

cbetter

2:59 am on Jul 15, 2009 (gmt 0)

10+ Year Member



Mmmm. Any reason why I couldn't redirect the 404 page to the homepage? Seems like this would accomplish the same goal.

If so, what's the best way to do this?

Thanks.

jdMorgan

3:32 am on Jul 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"Redirecting" the 404 page won't make any difference. As stated, all URLs which do not resolve to existing files or directories are already 'grabbed' by the WordPress code (as posted above) and sent to WordPress.

Your 404 page is irrelevant because it won't ever be invoked with that WP code in place.

Jim

cbetter

2:08 pm on Jul 15, 2009 (gmt 0)

10+ Year Member



Thanks, Jim. Just want to be sure I'm providing you with the right information.

Currently, if someone types www.mysite.com/a-file-that-doesn't-exist, they get a 404 error on my new Wordpress site. I'd rather they be redirected to my Wordpress site's homepage.

So, I'm not sure what you mean by "your 404 page...won't ever be invoked." Do you mean my "old" site's 404 page?

I haven't changed domain names. I simply moved my site from one host and CMS to another...and I want any URLs not currently specified by 301 to wind up on my NEW homepage.

Thanks.

cbetter

1:54 pm on Jul 22, 2009 (gmt 0)

10+ Year Member



Any response to my last query?

jdMorgan

5:27 pm on Jul 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, posted in my first post in this thread. Your code clearly states, "If the requested URI does not resolve to an existing files or directory, rewrite the request to WordPress' "index.php."

So with that code in place, you can't get a 404 handled by Apache (assuming that the .htaccess file is located at example.com/.htaccess) -- All requests that would result in a 404 would be handled by WordPress itself.

Jim