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
St_Aug_Beach_BumAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
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]
0
arober11Commented:
To permit index.php to be accessed and to offer a very slightly more efficiently solution, using %{REQUEST_URI} to avoid the slightly less efficient regexp logic above, you could use:

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*  http://www.newurl.com%{REQUEST_URI} [L,R=301]

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
St_Aug_Beach_BumAuthor Commented:
Thank you both very much.

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

Appreciate it very much!

Chris
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.