Jump to content

subdomains


dreamwest

Recommended Posts

ive set up subdomain rewrite as follows, the only problem is none of the other rewites work on the subdomian

 

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule (.*)$ http://www.site.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} !^www\.site.com
RewriteCond %{HTTP_HOST} ([^.]+)\.site.com
RewriteRule ^(.*)$ /home/site.com/index.php?lang=%1

# Main pages

RewriteRule ^$ index.php
RewriteRule ^view=(.*) index.php
RewriteRule ^sort=(.*) index.php
RewriteRule ^page=(.*) index.php

 

So if i go to http://www.site.com/view=1 it works but if i go to http://es.site.com/view=1 it only shows the main page aka http://es.site.com

 

Link to comment
https://forums.phpfreaks.com/topic/233931-subdomains/
Share on other sites

Ignore my last code this is what i have

 

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule (.*)$ http://www.site.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} !^www\.site.com
RewriteCond %{HTTP_HOST} ([^.]+)\.site.com
RewriteRule ^(.*)$ index.php?lang=%1

# Main pages

RewriteRule ^view/(.*)/(.*) index.php?nav=play&id=$1&t=$2 [L,QSA]

Link to comment
https://forums.phpfreaks.com/topic/233931-subdomains/#findComment-1202659
Share on other sites

When you add the ?lang=, you're changing the URL to be index.php. It's not /view/whatever anymore, so that last RewriteRule won't match.

 

Try

RewriteCond %{HTTP_HOST} !^www\.site.com
RewriteCond %{HTTP_HOST} ([^.]+)\.site.com
RewriteRule ^(.*)$ $1?lang=%1 [QSA]

Link to comment
https://forums.phpfreaks.com/topic/233931-subdomains/#findComment-1202752
Share on other sites

It works. But its also taking the first $1 from each rewrite

 

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule (.*)$ http://www.site.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} !^www\.site.com
RewriteCond %{HTTP_HOST} ^(ja|es|it|ar|pt|fr|de|hi|cn)\.site.com
RewriteRule ^(.*)$ $1?lang=%1 [QSA]

RewriteRule ^play/(.*)/(.*) index.php?nav=play&id=$1&t=$2 [L,QSA]

 

 

So:

 

http://ja.site.com/play/34/fun

 

The id comes back as "ja" but it should be "34"

 

 

Link to comment
https://forums.phpfreaks.com/topic/233931-subdomains/#findComment-1202772
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.