Whois.sc mod_rewrite

New to mod_rewrite? This is a good place to start.

Whois.sc mod_rewrite

Postby Rob83 » Fri Jul 17, 2009 1:47 pm

I'm trying to do something identical to whois.sc, where a user can type whois.sc/http://www.domain.com and it will 1) rewrite it to whois.scom/domain.com and then allow the script to query the info.

Using this
Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.+)$ /index.ch?url=$1 [QSA,L]


seems to work for mydomain.com/theirdomain.com.

Is there a way to, if they type "http://" to remove/rewrite it? So if they type http://www.mydomain.com/http://www.theirdomain.com, it can either pass the entire URL (http://www.theirdomain.com) to my check.php script, OR have mod_rewrite remove the http:// part?

Can anyone point me in the right direction?

Thanks
Rob83
 
Posts: 1
Joined: Fri Jul 17, 2009 1:43 pm

Postby richardk » Sat Jul 18, 2009 8:35 am

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^http:/(.+)$ /$1 [R=301,L]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.+)$ /index.ch?url=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 29 guests

cron