Forum Moderators: phranque
www.mydomain.com/index.php?id_pro=111 to www.111.mydomain.com
or
www.mydomain.com/index.php?id_pro=something to www.something.mydomain.com
I think that both are the same, i tried several rules but i cant get it !
this was the last rule i try:
rewriteEngine on
rewriteCond %{HTTP_HOST} ^(.+)\.mydomain\.com [NC]
rewriteCond %{HTTP_HOST) !^www\.
rewriteRule .* index.php?id_pro=%1 [L]
Thanks alot.
RewriteEngine on
#
RewriteCond %{REQUEST_URI} !^/(index\.php¦my_script\.php¦robots\.txt¦sitemap\.xml¦labels\.rdf¦w3c/p3p\.xml)$
RewriteCond %{REQUEST_URI} !\.(gif¦jpg¦jpeg?¦png¦ico¦css¦js¦avi¦mpe?g¦wav¦wmv¦mp3¦swf¦flv)$
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.example\.com
RewriteRule ([0-9]*)([0-9]*).html$ my_script.php?id_c=$1&id_pro=%2 [L]
I used ([0-9]*) to test whit numbers because whit the other way didnt work, but at least i know that the rule is fine, i will change that part in the near future.
Thanks a lot morgan, g1smd and phranque, i thought that this was going to be more difficult, i knew very little about mod rewrite.
RewriteEngine on
#
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.example\.com
RewriteRule ^([^.]+)\.html$ my_script.php?id_c=$1&id_pro=%2 [L]
I also got rid of the "(.*)(.*)" pattern, because it was ambiguous and because the second "(.*)" pattern would always result in an empty match. This is because the first "(.*)", being a "greedy" pattern, would have already matched as many characters as possible.
Jim