Forum Moderators: phranque
www.mydomain.com/subdirectory/ subdomain.mydomain.com/index.html www.mydomain.com/subdirectory subdomain.mydomain.com//var/.../.../subdirectory #.htaccess code on the subdirectory:
ErrorDocument 403 missing.html
AddHandler server-parsed .html .htm .shtml .shtm
Options +FollowSymLinks -Indexes -MultiViews
RewriteEngine On
## [1st entry] Move references [subfolder on main domain] to subdomain
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^(subdirectory/)?(.+)$ http://subdomain.mydomain.com/$2 [R=301,L]
## [Curiosity Try... DOES NOT get executed...to see what is trapped for the "$1"]
###If no trailing slash, and it is THIS subdirectory...add the "/index.html
RewriteCond %{HTTP_HOST} ^www\.complianceofficer\.com$
RewriteRule ^(.?)$ http://education.complianceofficer.com/$1junk [R=301,L]
#2nd curiosity try, which is also not executed with that problem URL
RewriteCond %{HTTP_HOST} ^www\.complianceofficer\.com$
RewriteRule ^(.+)$ http://education.complianceofficer.com/$1 [R=301,L]
## [ 1st try ] If no trailing slash, and it is THIS subdirectory...add the "/index.html -- [to see what the RuleSet finds...]
#RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
#RewriteRule ^(.+)$ http://subdomain.mydomain.com/$1 [R=301,L]
## [ 2nd try ]If no trailing slash, and it is THIS subdirectory...add the "/index.html/
#RewriteCond %{HTTP_HOST} ^www\.complianceofficer\.com$
#RewriteRule ^(subdirectory)$ http://education.complianceofficer.com/$1 [R=301,L]
## [ 3rd try ]If no trailing slash, and it is THIS subdirectory...add the "/index.html/
#RewriteCond %{HTTP_HOST} ^www\.complianceofficer\.com$
#RewriteRule ^(subdirectory)$ http://education.complianceofficer.com/index.html [R=301,L]
## other variants:
#using !^(.+)$ or !(.+) in the RewriteRule...[not any character...] ## If NOT a trailing slash and it IS a valid subdirectory....add the slash
RewriteCond $1 !(/$)
# and if URL with appended slash DOES exist as a directory
RewriteCond %{DOCUMENT_ROOT}/$1/ -d
# THEN externally redirect to subdir/index.html
RewriteRule ^(.+)$ http://www.complianceofficer.com/$1/ [R=301,L]
## Externally redirect requests for main-domain/subfolder/anything to subdomain/anything
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com
RewriteRule ^subdirectory(/(.*))?$ http://subdomain.example.com/$2 [R=301,L]
www.mydomain.com/subdirectory [note: NO trailing slash] ## [1st entry] Move references [subfolder on main domain] to subdomain
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteRule ^(subdirectory/)?(.+)$ http://subdomain.mydomain.com/$2 [R=301,L] (.+)", being empty, produces the exposed directory structure for the "$2", even though I would expect the $2 to also be empty/null.