Jump to content

subdomain mod_rewrite


vaskovasilev

Recommended Posts

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 .

 

Link to comment
Share on other sites

  • 2 months later...

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]

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.