Redirect problem

Using a single web hosting account to host multiple sites

Redirect problem

Postby Blast » Thu Feb 08, 2007 7:18 am

My problem is that every try to make subdomain is failed i tried many combinations and still nothing... Friendly URLs works.
I want to do :
www.whatever.domain.com -> www.domain.com/somelink/ and
whatever.domain.com -> www.domain.com/somelink/

Code: Select all
Options +FollowSymLinks
RewriteEngine On

RewriteBase /home/mysuser/www
///////////// FRIENDLY URLS  {
RewriteRule ^$ /index.php
RewriteRule ^([0-9a-z_]+)$ /$1/
RewriteRule ^([0-9a-z_]+)/$ /index.php?a=$1

RewriteRule ^([0-9a-z_]+)/([0-9a-z_]+)$ /$1/$2/
RewriteRule ^([0-9a-z_]+)/([0-9a-z_]+)/$ /index.php?a=$1&b=$2
////////////// } END OF F-URLS


RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([0-9a-z_]+)\.domain\.com$ [NC]
RewriteRule ^$ /index.php?a=%1 [L]
Blast
 
Posts: 2
Joined: Thu Feb 08, 2007 7:07 am

Postby richardk » Thu Feb 08, 2007 9:40 am

How is it failing? A timeout? A 404 error? A 500 error?
Have you got DNS for the sub domains?
Do the sub domains point to the directory on the server with the .htaccess file in it?

Code: Select all
Options +FollowSymLinks
DirectoryIndex index.php

RewriteEngine On

///////////// FRIENDLY URLS  {
RewriteRule ^([0-9a-z_]+(/[0-9a-z_]+)?)$ /$1/           [R=301,L]
RewriteRule ^([0-9a-z_]+)/$              /index.php?a=$1      [L]
RewriteRule ^([0-9a-z_]+)/([0-9a-z_]+)/$ /index.php?a=$1&b=$2 [L]
////////////// } END OF F-URLS


RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([0-9a-z_]+)\.domain\.com$ [NC]
RewriteRule ^$ /index.php?a=%1 [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Blast » Sun Feb 11, 2007 1:44 pm

Have you got DNS for the sub domains?
Do the sub domains point to the directory on the server with the .htaccess file in it?

Its 404 error, what do you mean by DNS for the sub domain , with bind ? Sub domins point to main directory with index.php and httacces, they are only kind of redirection ex. subdomain.domain.com = domain.com/index.php?a=subdomain.
Thanks for help.
Blast
 
Posts: 2
Joined: Thu Feb 08, 2007 7:07 am

Postby richardk » Sun Feb 11, 2007 2:48 pm

I mean you have to have a DNS record for each sub domain (or a wildcard record to allow every sub domain), like you have DNS for the main domain to send requests to the servers IP.

Then the server has to be setup to send the request to the directory with the .htaccess file, like how the server sends requests to your main domain to your public_html/ (or similar) directory. Mod_rewrite can only work when the request gets to the .htaccess file.

Its 404 error

If you go to subdomain.domain.com/index.php do you still get a 404 error? If you do, your sub domains probably aren't sent to the directory with the .htaccess file in it. Then you'll probably need to ask your host about it.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 34 guests

cron