Forum Moderators: phranque
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
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
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
# 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
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
[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]
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