Forum Moderators: phranque
Here's my quandry:
Site: www.examplesite.com
This is my main site.
I would like www.anotherexamplesite.com
to be directed to:
www.examplesite.com/oneofthepropertiesdirectory/index.htm
I am using apache server, and hoping to do this for a couple different domains to give our different properties more easily marketable domains.
I have done page redirects in the httpd.conf file but can't seem to figure out how to redirect an entire domain.
Any help would be greatly appreciated.
[edited by: DaveAtIFG at 6:57 pm (utc) on Sep. 15, 2003]
[edit reason] URLs generalized [/edit]
RewriteEngine on
RewriteRule ^www\.([^.]+)\.com(.*) http://www.examplesite.com/$1/$2
This should take the hostname used, and redirect it to the subdirectory (same name as the domain name) under the main site, and also pass long any pages requested.
[edited by: DaveAtIFG at 6:58 pm (utc) on Sep. 15, 2003]
[edit reason] URLs again [/edit]
External redirect - New URL shows in user's browser:
RewriteEngine on
RewriteCond %{HTTP_HOST}!^(www\.)?examplesite\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.com
RewriteRule ^(.*)$ http://www.examplesite.com/%2/$1 [R=301,L]
Internal redirect - New URL does not show in user's browser:
RewriteEngine on
RewriteCond %{HTTP_HOST}!^(www\.)?examplesite\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.com
RewriteRule ^(.*)$ /%2/$1 [L]
Jim
[edited by: DaveAtIFG at 7:23 pm (utc) on Sep. 15, 2003]
[edit reason] More URLs! [/edit]
RewriteEngine on
RewriteCond %{HTTP_HOST}!^(www\.)?examplesite\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.com
RewriteRule ^(.*)$ [examplesite.com...] [R=301,L]
This sounds good. Is there a certain place I place this in the httpd.conf file?
Can you also please provide me a little insight into where the first-domain-to-be-redirected.com and the redirected-to-site.com/site-dir/page.htm would go? Could you please clarify?
I tried to use generic terms in the first post, but I guess not generic enough.
Many thank you's.
This is for .htaccess in the web root of the site itself. If you're going to put this in a <directory> container in httpd.conf, it will require modification:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.)?requested_site\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.com
RewriteRule [b]^/([/b].*)$ http://www.target_site.com/%2/$1 [R=301,L]
Jim
I printed and tried to read the documentation last night, and again this morning but it pretty much goes right over my head.
From what I gather, it looks like that code should work, but the only part that throws me is the:
RewriteRule ^/(.*)$ [target_site.com...]
What is the /%2/$1 for?
I want redirect the requested_site to a specific file in the target site.This is for .htaccess in the web root of the site itself. If you're going to put this in a <directory> container in httpd.conf, it will require modification:
A bit off-subject here but......Am I correct in assuming if I place a file in the root directory named ".htaccess" it will be found and executed by the server? I remember trying this before and only having success in configuring with the httpd.conf file (although it seemed that .htaccess was turned on in the httpd.conf file)I'm not sure whether your question is about patterns versus substitutions, or about backreferences; If you have any questions about what is what, I strongly advise you to read the Apache mod_rewrite documentation before proceeding - mod_rewrite is strong medicine...I'm not real sure either....I am very careful to change anything back to its original state if it doesn't have the intended effect though. I'm kinda skiddish about messin' with our webserver too aweful much.
One last note.....I'm not sure what (if any) difference this will make, but our "host" (provider of our T1) point the "requested_site" to the TOP LEVEL of the domain that contains the file I want to redirect to.
Site: www.examplesite.com
This is my main site.
I would like www.anotherexamplesite.com to be directed to:
www.examplesite.com/oneofthepropertiesdirectory/index.htm
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?anotherexamplesite\.com
RewriteRule .* http://www.examplesite.com/oneofthepropertiesdirectory/index.htm [R=301,L]
Am I correct in assuming if I place a file in the root directory named ".htaccess" it will be found and executed by the server? I remember trying this before and only having success in configuring with the httpd.conf file (although it seemed that .htaccess was turned on in the httpd.conf file)
I have tried both methods, and neither seem to work. The site is still be redirected to the top level of the primary domain.
Are the settings of my ISP overriding mine? Or am I missing something. I've double checked the code, and I didn't get any errors when I restarted the webserver.
Any ideas? I have the code listed in <directory "/">
>>Internal redirect - New URL does not show in user's browser:
RewriteEngine on
RewriteCond %{HTTP_HOST}!^(www\.)?examplesite\.com
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.com
RewriteRule ^(.*)$ /%2/$1 [L]
<<
Can one also use this method for hiding a .zip file for downloads so it cannot be leached? Example, I have a script that adds to a log when someone downloads the program, but you can see the URL in the browser, so they can just build a link to the .zip file. Will this hide the URL?