vaskovasilev Posted June 28, 2012 Share Posted June 28, 2012 Hello to all , i have some problems with mod_rewrite rules and i aks for help . i have working code that redirects domain.com/username/servicesid to domain.com/index.php?page=Profile&user=username&services_id=servicesid i want to make subdomain rewrite .. username.domain.com/servicesid to the same url domain.com/index.php?page=Profile&user=username&services_id=servicesid here is my code : RewriteRule ^([^/]+)/([a-z\d]{32})/(\d{4}-\d{2}-\d{2})$ index.php?page=Profile&user=$1&services_id=$2&date=$3 [L] RewriteRule ^([^/]+)/([a-z\d]{32})$ index.php?page=Profile&user=$1&services_id=$2 [L] RewriteCond %{REQUEST_FILENAME} !-f this is for rewriting only the subdomain : RewriteCond %{HTTP_HOST} !www.domain.com$ [NC] RewriteCond %{HTTP_HOST} ^(www.)?([^/]+).domain.com [NC] RewriteRule (.*) index.php?page=Profile&user=%2 [NC,QSA] can you please help me to make the code working . also when i open username.domain.com , i cannot open the css , js .. images files . Quote Link to comment Share on other sites More sharing options...
handlegeek Posted August 28, 2012 Share Posted August 28, 2012 Try to have a URL pattern like /service to be more specific and not apply to images/static files. For example http://123.domain.com/service/456 -> http://www.domain.com/index.php?page=Profile&user=123&services_id=456 Following rule will work: RewriteEngine On RewriteCond %{HTTP_HOST} !^www.domain\.com$ [NC] RewriteCond %{HTTP_HOST} ^(.+)\.domain.com$ [NC] RewriteRule ^service/(.*)[$ index.php?page=Profile&user=%1&services_id=$1 [L] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.