Shoutbox

Mod_Rewrite help - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Mod_Rewrite help (/showthread.php?tid=86367)

Mod_Rewrite help by Dempsey on 10-02-2008 at 09:11 PM

Wondering if anyone can help me with Mod_Rewrite?

I have a domain called Whois setup to point at my main domain, and have this in my .htaccess file:

code:
RewriteCond %{HTTP_HOST} ^(www\.)?whois.mydomain.com
RewriteRule ^$ /whois.php?d=$1 [L]

Now I'm trying to make it so whatever is apended after the domain gets passed as a variable to the script, eg
whois.mydomain.com/google.com would call whois.php?d=google.com

I got a regex to match a domain (/([a-z0-9.-]+\.[a-z]{2,4})/i) but can't get it to work, and am a bit stuck now so wondered if anyone can help.

Any help will be greatly appreciated :-)


RE: Mod_Rewrite help by Mike on 10-03-2008 at 04:01 AM

You should be able to modify step 3 from [url=http://www.mediawiki.org/wiki/Manual:Short_URL/wiki/Page_title_--_no_root_access]here[/url] to achieve what you want :)


RE: Mod_Rewrite help by WDZ on 10-03-2008 at 06:02 AM

Tested and working with this .htaccess file:

code:
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?whois\.mydomain\.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([a-z0-9.-]+\.[a-z]{2,4})$ /whois.php?d=$1 [L,NC]
The second RewriteCond prevents an infinite loop (because the domain regex matches "whois.php"), and the [NC] flag is used instead of the 'i' modifier.
RE: Mod_Rewrite help by Dempsey on 10-03-2008 at 08:13 AM

Thanks WDZ works perfect :D


RE: Mod_Rewrite help by Forcegames on 10-05-2008 at 10:02 PM

wow o.o I'm wondering
i've had a problem with mod_rewrite too, some time ago. i posted it in a special "Mod rewrite Forum" but no one cared xD I guess my chances here are a bit better here xD unfortunately my english is too bad to formulate my problem in english rather than german :D

Damn it ^^


RE: Mod_Rewrite help by Menthix on 10-05-2008 at 10:19 PM

Your English doesn't seem *that* bad. Why not give it a try? Post the same in both German and English if you like, there are some German speakers here that could help you out.