Mod Rewrite: Multiple redirections, check if numeric

Posted on 2008-11-19
Last Modified: 2012-05-07
Hi all.
I would like to redirect numeric values to one site1.php and the rest to site2.php

For example: should be directed internally to to to to

This is what I've got so far:
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteCond %{SCRIPT_FILENAME} !-d

RewriteRule (.*)$1 [L]

Open in new window

Question by:husker475
    LVL 27

    Accepted Solution

    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

    LVL 4

    Author Closing Comment

    Thank you thank you thank you, works great!

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
    Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now