Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

Mod Rewrite: Multiple redirections, check if numeric

Hi all.
I would like to redirect numeric values to one site1.php and the rest to site2.php

For example:
www.mydomain.com/123 should be directed internally to www.mydomain.com/site1.php?id=123
www.mydomain.com/1234 to www.mydomain.com/site1.php?id=1234
www.mydomain.com/abc to www.mydomain.com/site2.php?name=abc
www.mydomain.com/abc12 to www.mydomain.com/site2.php?name=abc12

This is what I've got so far:
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule (.*) http://www.domain.com/site1.php?name=$1 [L]

Open in new window

0
husker475
Asked:
husker475
1 Solution
 
caterham_wwwCommented:
I don't think that you need to exclude existing files and dirs since I expect that you don't have extensionless files.
RewriteEngine on
RewriteRule ^([0-9]+)$ /site1.php?name=$1 [L]
RewriteRule ^([a-z0-9]+)$ /site2.php?name=$1 [L]

Open in new window

0
 
husker475Author Commented:
Thank you thank you thank you, works great!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now