Forum Moderators: phranque
My problem is this
1. I have a main domain www.main.com
2. I have a parked domain www.parked.com. The name server configuration for the parked domain has been done.
Now I need the rewrite rules for the following -
www.parked.com will redirect to www.main.com/user/parked/default/index.html
www.parked.com/files will redirect to www.main.com/user/parked/default/files/index.html
In the www.main.com/user/parked/default directory there are files like index.html,profile.html etc. and also other directories like files,images etc. which also have html files. HTML files in a directory are linked. So in index.html there may be link to profile.html and the link is set like <a href="profile.html">Profile</a>. At present I can do the redirect to index.html with the following rule
RewriteRule ^/?(index.html¦cat)?$ [main.com...]
If I click a link in the index.html file, it does not work. Also I have not been able to figure the rule for redirecting to a sub-directory.
I will really appreciate any help.
Thanks
--visual--
Thanks again
--visual--
There are many examples of domain-to-subfolder rewrite threads posted here, some very recent.
Also, if the "parked.com" site is being hosted in the same server space as "main.com," then the rule will need to examine HTTP_HOST so that it only redirects parked.com to "main.com/user/parked" instead of redirecting any host (including main.com) to main.com (this would create an 'infinite' redirection loop). So if all of these domains are hosted in the same server file space, the rule would need to be something like this:
RewriteCond %{HTTP_HOST} ^(www\.)?parked\.com
RewriteRule ^/?(.*)$ http://www.main.com/user/parked/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.parked.com$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ [main.com...] [R=301,P,L]
RewriteCond %{REQUEST_URI} ^/(.+)\.html$ [NC]
RewriteCond %{REQUEST_URI} !^/(.*)/(.+)\.html$ [NC]
RewriteRule ^(.*)$ [main.com...] [R=301,P,L]
RewriteCond %{REQUEST_URI} ^/user-([0-9]+)/$ [NC]
RewriteRule ^(.*)$ [main.com...] [R=301,P,NC,L]
RewriteCond %{REQUEST_URI} ^/user-([0-9]+)/(.+)\.html$ [NC]
RewriteCond %{REQUEST_URI} !^/user-([0-9]+)/(.*)/(.+)\.html$ [NC]
RewriteRule ^(.*)$ [main.com...] [R=301,P,NC,L]
I am now giving the user directories names like user-1,user-2 etc. These have solved my problems to a great extent and the links are working. Only problem is that www.parked.com/user-1 will not work properly but www.parked.com/user-1/ will work and www.parked.com/User-1/ or www.parked.com/USER-1/ will not work either. In any case I will check these problems and also I have learned the basics of Regular Expressions. I will appreciate any suggestions.
Thanks,
--visual--