Avatar of Chris Andrews
Chris AndrewsFlag for United States of America asked on

htaccess - redirecting if no match

Ok, currently in my .htaccess file I have:

---------------------------------------
RewriteEngine on
RewriteRule ^([0-9]+)$ index.php?p=$1 [L]
--------------------------------------

It's designed so that if something like this comes in:

http://url.com/85344

it will take that number, assign it to $p, and then run it through index.php so I can process it.

That works great and I need to keep that process.

Now.... what I would like to do is have any url that does not match that format (url.com/NUMBER) to be forwarded to another domain intact (maintaining its directory structure).

So that:

 http://url.com  is redirected to http://www.newurl.com

and

http://url.com/about  is redirected to http://www.newurl.com/about

and so on... but only if it does not match the url.com/83948 type format.

Is that possible?

Thanks, Chris
Apache Web Server

Avatar of undefined
Last Comment
Chris Andrews

8/22/2022 - Mon
arnold

Add a fall through rule below the existing one.
Redirect ^(.*)$ http://www.newurl.com/$1
Or
RewriteRule ^(.*)$ http://www.newurl.com/$1 [r=301,L]
ASKER CERTIFIED SOLUTION
arober11

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Chris Andrews

Thank you both very much.

I tested both of these and this is the one that worked out.

Appreciate it very much!

Chris
Your help has saved me hundreds of hours of internet surfing.
fblack61