It must be something wrong somewhere because some of the rules do not work as they should.
I only replaced the domain part using domain.tld because this is a public forum.
My Apache information as taken from phpinfo() is
- Code: Select all
apache2handler
Apache Version Apache/2.0.54 (Fedora)
Apache API Version 20020903
Server Administrator root@localhost
Hostname:Port www.domain.tld:0
User/Group apache(48)/48
Max Requests Per Child: 1000 - Keep Alive: off - Max Per Connection: 100
Timeouts Connection: 120 - Keep-Alive: 15
Virtual Server Yes
Server Root /etc/httpd
Loaded Modules core prefork http_core mod_so mod_access mod_auth mod_auth_anon mod_auth_dbm mod_auth_digest util_ldap mod_auth_ldap mod_include mod_log_config mod_logio mod_env mod_mime_magic mod_cern_meta mod_expires mod_deflate mod_headers mod_usertrack mod_setenvif mod_mime mod_dav mod_status mod_autoindex mod_asis mod_info mod_dav_fs mod_vhost_alias mod_negotiation mod_dir mod_actions mod_speling mod_userdir mod_alias mod_rewrite mod_proxy proxy_ftp proxy_http proxy_connect mod_cache mod_suexec mod_disk_cache mod_file_cache mod_mem_cache mod_cgi mod_evasive20 mod_perl mod_php5 mod_python mod_ssl
Directive Local Value Master Value
engine 1 1
last_modified 0 0
xbithack 0 0
This is the .htaccess that is there:
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
# Strip www. (Doesn't work if uri is /cgi-bin or /icons.)
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule .* http://%1/$1 [R=301,L]
# mod_dir fix.
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain.tld$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI}/ -d
RewriteRule !/$ %{REQUEST_URI}/ [R=301,L]
# If directory exists for subdomain, rewrite it.
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain.tld$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1/ -d
RewriteCond %1%{REQUEST_URI} !^([^\.]+)/\1(/.*)?$
RewriteRule ^(.*)$ /%1/$1 [QSA,L]
# Directory doesn't exist for subdomain.
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain.tld$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%1/ !-d
RewriteRule .* http://www.a-diferent-domain.tld/ [R=301,L]
# /subdomain/ --> subdomain.domain.tld
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_URI} ^/([^/]+)(/.*)?$
RewriteCond %{DOCUMENT_ROOT}/%1/ -d
RewriteRule .* http://%1.domain.tld%2 [R=301,L]
The .htaccess doesn't work, except the rule that redirects to the magazine.
Tried with:
- www.domain.tld and domain.tld -> redirects to the a-diferent-domain.tld as it should
- www.domain.tld/subdomain/ -> redirects as #1 even if the dir exists and it should rewrite to subdomain.domain.tld/
- domain.tld/subdomain/ -> redirects as #1 but to /subdomain/ even if the dir exists and it should rewrite to subdomain.domain.tld/
- http://subdomain.domain.tld/ -> returns page load error, address not found
- http://www.subdomain.domain.tld/ -> returns page load error, address not found
This is the current .httpd.conf section related with my domain
- Code: Select all
<VirtualHost *:80>
DocumentRoot /home/lopo/data/htdocs
ServerAlias *.domain.tld
ServerName www.domain.tld
CustomLog /home/lopo/logs/access_log common
ScriptAlias /cgi-bin/ /home/lopo/data/cgi-bin/
#RedirectMatch 301 (.*) http://domain.tld$1
<Directory /home/lopo/data/htdocs>
AllowOverride All
</Directory>
</VirtualHost>
Help please.