Forum Moderators: phranque

Message Too Old, No Replies

how To Get Subdomain Name Separately?

Get Subdomain Name Separately using htaccess rewrite rules

         

nad2zen

10:17 am on Aug 19, 2008 (gmt 0)

10+ Year Member



Hi to all,

I am sarah. New to this forum & also to .htaccess rules too. I am currently in a development of php website using drupal and it requires a subdomain feature. Please help me how to solve the below issue using the Rewrite rules

My Requirement is:

Consider this url : http://abc.example.com/index.php?q=home . Using the .htaccess rules i need to redirect the request as : http://abc.example.com/index.php?q=community/abc/home

Here the string "community" is an static text and the subdomain name "abc" is required to insert in the middle of the two strings (like community/abc/home). Here "q" is an querystring value.

Is it possible to write a rule like this? Or please give me any suggestions how to resolve this issue.

Thanks in advance..
Sarah

[edited by: jdMorgan at 1:59 pm (utc) on Aug. 19, 2008]
[edit reason] example.com [/edit]

jdMorgan

1:58 pm on Aug 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Extract the subdomain from the %{HTTP_HOST} server variable using RewriteCond, enclosing the subpattern in parentheses to create a back-reference.

Then insert that back-referenced value (as "%1") into the substitution URL if the requested URL-path matches in the RewriteRule.

Take a look at the mod_rewrite documentation and other resources cited in our Forum Charter (link at top of this page). There are also many previous threads here related to using the subdomain name in a query string -- Try this site search [google.com].

Once you've reviewed these resources, please post your best effort at a coded solution, and we'd be glad to help you get it working.

Thanks,
Jim