Forum Moderators: phranque

Message Too Old, No Replies

Domain name stack - return on main site? Why?

stack return on main site

         

redman

1:29 pm on Dec 28, 2003 (gmt 0)

10+ Year Member



Hello everybody,

I have a problem with a domain stacked on my main domain name (website1.com) i explain you, when i try to access my stack (website2.com) by the address:

[website2.com...] all work well but if i remove the slash after the folder web the address is converted to [website1.com...]

I would like that all the time the address website2.com remain website2.com

Below are the .htaccess that i have.

=================
First htaccess
=================

Options FollowSymLinks Includes +ExecCGI

order allow,deny
allow from all

DirectoryIndex index.html index.shtml /cgi-php/illegal_access.cgi

ErrorDocument 404 [website1.com...]

AddType application/x-httpd-php .php4 .php3 .phtml .php

###*****first htaccess file for parent account folder
Options +FollowSymlinks
Options +Includes +ExecCGI
RewriteEngine on
RewriteCond %{HTTP_HOST} [^.]*website2\.com$
RewriteRule ^(.*)$ /website2/$1

=================
Second htaccess - in the folder website2 of the main domain name
=================

order allow,deny
allow from all

DirectoryIndex index.html index.shtml

ErrorDocument 404 [website2.com...]

AddType application/x-httpd-php .php4 .php3 .phtml .php

##*****second htaccess file for destination folder******
Options +Includes +ExecCGI

Options +FollowSymlinks
RewriteEngine off

--------------------------------------------

How solve this problem? Any suggestion?

Thanks

Redman

redman

8:43 pm on Dec 29, 2003 (gmt 0)

10+ Year Member



I always waiting for an answer ;) wink

Any suggestions?

Redman

jdMorgan

8:58 pm on Dec 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



redman,

Welcome to WebmasterWorld [webmasterworld.com]!

I've looked at this several times, and can't quite figure out the problem. There are actaully several problems here. But we're not ignoring you, it is just confusing.

Jim

redman

9:28 pm on Dec 29, 2003 (gmt 0)

10+ Year Member



JdMorgan,

Thanks for your reply.

I found this page on the apache website [httpd.apache.org...]

"The ServerName and UseCanonicalName directives are used by the server to determine how to construct self-referential URLs. For example, when a client requests a directory, but does not include the trailing slash in the directory name, Apache must redirect the client to the full name including the trailing slash so that the client will correctly resolve relative references in the document."

I would like make the stack work with a htaccess and not with the server configuration (i don't have access to them)

Redman

jdMorgan

7:20 am on Dec 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This .htaccess code should fix the missing-trailing-slash problem in almost all cases, but it does not support *all* valid Unix filenames. For example, it supports a file named like ".htaccess" (with no filename and only a filetype), but not a file named "valid." (a filename without any filetype).

# IF URI does not end with "/"
RewriteCond %{REQUEST_URI} !/$
# and IF URI does not end with <something> <dot> <something>
RewriteCond %{REQUEST_URI} ![^.]*\.[^.]+$
# THEN append trailing slash and redirect the client
RewriteRule (.*) /$1/ [R=301,L]

Ref: Introduction to mod_rewrite [webmasterworld.com] (See link to regular-expressions tutorial)

Jim

redman

7:26 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



i tested the last code, i have always the same problem :-¦

Any other suggestions?

Redman

uncle_bob

7:32 pm on Dec 30, 2003 (gmt 0)

10+ Year Member



I had a similar issue with virtual hosts, and it was down to the servername part for the virtual host declaration.

when you try to access http*//domain.com/dir apache will give you a 301 permanently moved response telling you to go to
http*//domain.com/dir/ , however apache works out where to send you from the servername part of the virtual host.

Of course your problem could be something else completely

redman

5:51 pm on Jan 2, 2004 (gmt 0)

10+ Year Member



Thanks to all for your answers, but ifound a solution on this forum

[forums.devshed.com...]

======================
1st htaccess
======================

Options FollowSymLinks Includes +ExecCGI

order allow,deny
allow from all

DirectoryIndex index.html index.shtml

ErrorDocument 404 [website1.com...]

AddType application/x-httpd-php .php4 .php3 .phtml .php

###*****first htaccess file for parent account folder
Options +FollowSymlinks
Options +Includes +ExecCGI
RewriteEngine on
RewriteCond %{HTTP_HOST} [^.]*website2\.com$
RewriteRule ^(.*)$ /website2/$1

======================
2nd htaccess
======================
order allow,deny
allow from all

DirectoryIndex index.html index.shtml

ErrorDocument 404 [website2.com...]

AddType application/x-httpd-php .php4 .php3 .phtml .php

##*****second htaccess file for destination folder******
Options +Includes +ExecCGI

Options +FollowSymlinks
#RewriteEngine off

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ [website2.com...] [R,L]

jdMorgan

6:41 pm on Jan 2, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



redman,

Be aware that using a full URL as the destination for ErrorDocument will cause your server to return a 200-OK response, instead of 404-Not Found. In the case of files which are truly missing, this can seriously confuse search engines and affect your page listings negatively. See the Apache ErrorDocument documentation for specific warnings.

Using the '-d' and '-f' options in RewriteConds for specific missing files as you posted above is better than using "ErrorDocument 404 http://www.website2.com" because it redirects only missing files which exist in the other domain, and not *all* missing files.

Jim