Results 1 to 7 of 7
  1. #1

    mod_rewrite - Redirect every URL... (Whois.sc redirection)

    I need some help with a mod_write problem. I'm trying to do exactly what www.whois.sc does with the domains at the end like this:
    http://www.whois.sc/webhostingtalk.com

    Any and all domain in the form of that or any other type of forms like:
    http://www.webhostingtalk.com
    http://webhostingtalk.com
    www.webhostingtalk.com
    webhostingtalk.com
    http://www.webhostingtalk.com/
    http://webhostingtalk.com/
    www.webhostingtalk.com/
    webhostingtalk.com/

    They all need to be redirected to one file, let's say domain.php?domain=DOMAIN_HERE.

    Can anyone help me figure this out?

    I'm paying $10 to the first person who posts an htaccess fix for this.

  2. #2
    Code recieved on another forum.

  3. #3
    Join Date
    May 2004
    Location
    Lansing, MI, USA
    Posts
    1,548
    Quote Originally Posted by CreativeLogic
    I need some help with a mod_write problem. I'm trying to do exactly what www.whois.sc does with the domains at the end like this:
    http://www.whois.sc/webhostingtalk.com

    Any and all domain in the form of that or any other type of forms like:
    http://www.webhostingtalk.com
    http://webhostingtalk.com
    www.webhostingtalk.com
    webhostingtalk.com
    http://www.webhostingtalk.com/
    http://webhostingtalk.com/
    www.webhostingtalk.com/
    webhostingtalk.com/

    They all need to be redirected to one file, let's say domain.php?domain=DOMAIN_HERE.

    Can anyone help me figure this out?

    I'm paying $10 to the first person who posts an htaccess fix for this.
    RewriteEngine On
    RewriteRule ^(.*)\.php$ $1.php [L]
    RewriteRule ^(.*)$ file.php?DOMAIN=$1

    I believe should work for ya, though YMMV
    Jacob - WebOnce Technologies - 30 Day 100% Satisfaction Guarantee - Over 5 Years Going Strong!
    Website Hosting, PHP4&5, RoR, MySQL 5.0, Reseller Hosting, Development, and Designs
    Powered By JAM - Professional Website Development - PHP, MySQL, JavaScript, AJAX - Projects Small & Large

  4. #4
    That's the code I had before and it didn't work all the time. Sometimes it would give a 404 error.

  5. #5
    Join Date
    May 2004
    Location
    Lansing, MI, USA
    Posts
    1,548
    The exact code? hum. Only way I can see it would cause issues is if they put in http://www.somesite.com/index.php or whatever, which it isn't really meant for anyway... probably just need to add a RewriteCond on SCRIPT_FILENAME... like

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^$
    RewriteRule ^(.*)$ file.php?DOMAIN=$1 [L]
    Jacob - WebOnce Technologies - 30 Day 100% Satisfaction Guarantee - Over 5 Years Going Strong!
    Website Hosting, PHP4&5, RoR, MySQL 5.0, Reseller Hosting, Development, and Designs
    Powered By JAM - Professional Website Development - PHP, MySQL, JavaScript, AJAX - Projects Small & Large

  6. #6
    Mod_rewrite allows regex so that's reasonably easy. Something like this should work

    RewriteRule ^((http:\/\/)?(www)?\.?(.+?)(\.[a-z]{3,4})\/?)$ domain.php?domain=$4$5

    $1 contain the entire entry http://www.somesite.com/
    $2 contain http:// (if entered)
    $3 contains www (if entered)
    $4 contains somesite
    $5 contains .com

  7. #7
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ info.php?domain=$1 [L]

    That's the code I'm using...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •