Forum Moderators: phranque
Then I removed .htaccess file what i used to create subdomains. The problem is gone.
I don't know what's wrong with mod_rewrite. Please see my .htaccess file below. Is it OK?
I used mod_rewrite for the following purpose: when an user registers and creates a profile at my site, his/her profile is accessible via:
[domain.com...]
mod_rewrite was used to access user profiles via subdomain: [username.domain.com....]
Most of time it works fine, but sometimes when I try to access some subdomain, nothing loads (I get "page cannot be displayed" error which usually appears when server is down, but my server is not down).
My .htaccess file:
=============
RewriteEngine On
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteCond %{HTTP_HOST}!^domain\.com [NC]
RewriteCond %{HTTP_HOST} ^[^.]+\.domain\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.domain\.com(.*) go.php?to=myaccount&op=userinfo&uname=$1
RewriteCond %{HTTP_HOST} ^www\.[^.]+\.domain\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^www\.([^.]+)\.domain\.com(.*) go.php?to=myaccount&op=userinfo&uname=$1
========
Thanks for your help.
Ainars
Welcome to WebmasterWorld [webmasterworld.com]!
I see one anomaly and one potential problem:
First, you have two "RewriteEngine on" directives - Delete the first one.
Second, the following regular expression may be a problem for you:
^[^.]+
The "+" requires the group to contain a character, but the group is defined as "^.", which means "not any character." In regular expressions, a "." is a special symbol, and matches any character.
If you wish the group to be defined as "any character except ".", then you must escape the "." with a preceding backslash. The result would be:
^[^\.]+
I don't know if this will correct your problem, but it may help to reveal the actual problem more clearly.
HTH,
Jim
You may or may not know this, but seems like a good palce to ask...
Do you only need to turn mod_rewrite on once per DOMAIN, or once per DIRECTORY, or once per SERVER?
Say I have 7 Virtual Hosts on my server.... I will need to turn it on 7 times (once for each host), right? Do I need to turn it on in /root/, or how about /root/sub1/ (and then will it only effect there down)?
Thanks!
dave
You can try this much-simplified version of your code. I think it will accomplish what you need in a much simpler way.
If it does not work, I suggest you locate and hire a local expert to help you debug this problem - someone who can actually stand there and look over your shoulder to see the problem - It sounds like it could be a difficult one.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !go\.php
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.domain\.com [NC]
RewriteRule .* /go.php?to=myaccount&op=userinfo&uname=%2 [L]
I noticed one more problem - with wildcarded DNS. In my first post I wrote: "sometimes when I try to access some subdomain, nothing loads (I get "page cannot be displayed)". I just noticed that this happends even if I don't use mod_rewrite.
I have 2 domains, let's say:
domain.lv
domain.lt
One hour ago [anything.domain.lv...] was working fine, but when I tried to access [anything.domain.lt...] - I got "page can not be displayed". I checked httpd.conf file, zone files, but nothing wrong - both domains have similar settings. I restarted DNS services, Apache, but no success - wildcards for domain.lv work fine, but for domain.lt not.
At the same time i was able to access both domains with "www" and without "www".
After some hour both domains started to work fine with addresses like [anyword.domain.lv...] and [anyword.domain.lt....]
It happends every day. I was thinking it's due to mod_rewrite, but now I see that it's another problem. I am getting crazy...