Forum Moderators: phranque
RewriteEngine On
# Extract the subdomain part of domain.com
RewriteCond %{HTTP_HOST} ^www\.([^.]+)\.ioo\.ir$ [or]
RewriteCond %{HTTP_HOST} ^([^.]+)\.ioo\.ir$ [or]
# Check that the subdomain part is not www and ftp and mail
RewriteCond %1 !^(www¦ftp¦mail)¦()$ [NC]
# Redirect all requests to a php script passing as argument the subdomain
RewriteRule ^.*$ product.php?product_id=%1
but now i change my webhost and it dosent work !
i try a dozen type of .htaccess code for this.
and i check and see that the mod_rewrite work well ,
this problem take 2 days of me , please help me .
<snip>
thanks for your help
[edited by: jdMorgan at 4:18 pm (utc) on Mar. 25, 2009]
[edit reason] Do not post personal info -- Thanks! [/edit]
# Check that the (sub)-subdomain is not www and ftp and mail
RewriteCond %{HTTP_HOST} !^(www\.)?(www¦ftp¦mail)\.example\.com [NC]
#
# Extract the (sub)-subdomain part of sub.example.com (with optional leading "www.")
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.example.\.com
#
# Internally rewrite all requests to script, passing the subdomain in query string as "product_id"
RewriteRule ^.*$ product.php?product_id=%2 [L]
Note that it is not necessary to check explicitly for a blank sub-subdomain; Any request with a blank sub-subdomain will not match the second RewriteCond.
Important: Replace the broken pipe "¦" characters with a solid pipe before use; Posting on this forum modifies the pipe characters.
I should also note that www.xyz.example.com is a sub-sub-domain, and there is little reason to require your users to enter long, ugly domain names that way: "xyz.example.com" for products and "www.example.com" for the main site would make a lot more sense. See for example "search.yahoo.com"
Remember to completely flush your browser cache before testing any new server-side code.
Jim
[edited by: jdMorgan at 5:09 pm (utc) on Mar. 25, 2009]
thanks for your replays but my problem is still alive!
Dear g1smd
I want to rewrite.
and i test other simple rewrite code that sho the mod_rewrite is enable . (i test this for checking that :
RewriteRule (.*) [yahoo.com...]
and this work well
and i find out that my mod_rewrite module is enable)
Dear jdMorgan
i test your code and unfortunately it does not work
i check every thing that i can but i'm not an expert in this field
i put my host username and password here ,
if anyone can go and correct my mistakes , (Please Help)
<snip>
thank a lot
[edited by: jdMorgan at 12:32 am (utc) on Mar. 26, 2009]
[edit reason] Do not post personal information. [/edit]