.htaccess - Can I redirect a subdomain to a particular webpage and process the subdomain value with PHP -
i familiar modifying htaccess files not sure if following possible:
ultimately, want point users 'imaginary' subdomains (those not exist) subdomain can parsed correctly php , mysql find particular member's information.
for example:
when goes www.site.com currently, shows parent site including information on how become member. once person member, 'unique' url is:
www.site.com?memberid=12345
ultimately, forcing member remember question mark agent equals can confusing along need remember proper capitalization , such.
i 'like' achieve following:
www.12345.site.com
redirects
www.site.com/index.php (and index.php reads 12345 $_get function lookup id, valid , retun response based on that.
i realize achieve same using information after hash:
e.g. www.site.com/12345
but issue have other pages using /xxxx modify client content don't want block anybody's ability visit: www.site.com/contact example
(where site redirects index, tries memberid = 'contact' , not find results).
intiial thoughts:
options +followsymlinks rewriteengine on rewritecond %{http_host} ^subdomain.example.com$ [nc] rewriterule (.*) http://subdomain.example.com/$1 [r=301,l]
but doesn't seem work. note: htaccess file strips file exnteions pages (i.e. www.site.com/contact.php displays www.site.com/contact)
any appreciated.
update regarding first suggestion -
my .htaccess currently:
errordocument 404 /404.php options +followsymlinks rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename}.php -f rewriterule ^(.*)$ $1.php rewritecond %{http_host} ^(\w+).site.com$ [nc] rewriterule (.*) /subdomain.php?id=%1 [l]
i expect based off needs typing www.something.site.com redirected to: www.site.com/processing_page.php?something
instead, redirects mediatemple hosting page (essentially stating no subdomain named 'something' exists.
if go www.site.com, throws 503 error:
internal server error server encountered internal error or misconfiguration , unable complete request. please contact server administrator, email , inform them of time error occurred, , might have done may have caused error. more information error may available in server error log. apache server @ www.contendertest.com port 80
the apache error log states:
[thu jan 27 12:43:37 2011] [error] [client 1.2.3.4] request exceeded limit of 10 internal redirects due probable configuration error. use 'limitinternalrecursion' increase limit if necessary. use 'loglevel debug' backtrace.
attempt 2
my .htaccess file stripped to:
rewritecond %{http_host} !^www\. rewritecond %{http_host} ^(.+)\.site\.com rewriterule .* http://site.com/processing_page.php?id=%1 [l,r]
this still directs media temple random landing page however.
your looking "rewritecond backrefereces". take form %1
rather usual $1
current rewriterule.
so example might like:
rewritecond %{http_host} ^(\w+).example.com$ [nc] rewriterule (.*) /subdomain.php?id=%1 [l]
Comments
Post a Comment