Forum Moderators: phranque
My issues are :
1) .htaccess in http://www.example.com/quux-foo/
Options +FollowSymLinks
RewriteEngine on
#
# Prevent .htaccess recursion if index.php is requested
RewriteCond $1 !^index\.php$
# else do the rewrite
RewriteRule ^(.*)$ "http\:\/\/www\.quux-foo\.com\/" [L]
This redirects to http://www.quux-foo.com without keeping http://www.example.com/quux-foo/ in the status bar
2)The Referrer Url server variable is not detected.
I would appreciate if there's a solution to my 2 issues, most especially the 1st issue.
[edited by: jdMorgan at 2:42 am (utc) on Oct. 24, 2008]
[edit reason] non-resolving domains example.com & quux-foo [/edit]
All-in-all, the HTTP Referer should not be used for anything that is important and has to work 100% of the time. If your plans depend on this, you're going to have to find a better way such as including the referrer in the link itself (as a query string parameter), or using a different URL-path (or subdomain) per referrer.
As g1smd says, you'll also need to make sure that search engines are always redirected to one and only one version of the site at one and only one URL. Otherwise, you have to deal with the risks of duplicate content: You will not get to choose which URL they show, or which version of the site they index. This code needs to be based on a frequently-maintained list of search engine IP addresses -- It must be 'bulletproof' and you may have to pay an outside service to be sure your IP list is up-to-the-minute fresh. Also, do not promote multiple domains or multiple versions of the site -- only one.
Jim
# Prevent .htaccess recursion if index.php is requested
RewriteCond $1 !^index\.php$
# else do the rewrite
RewriteRule (.*) http://www.quux-foo.com/ [R=302,L]
If a redirect is implied by the use of a canonical substitution URL, it is best practice to specify whether a 300, 301, 302, 303, or 307 redirect is desired.
Also, to add to the general discussion, if example.com and quux-foo.com are not hosted in the same server filespace, then you may need to reverse proxy requests from example.com to the quux-foo application server. See Apache mod_proxy for details. There are several complications, in that you may need to configure example.com to send the X-Forwarded-For HTTP header containing the original requestor's IP address, and set up custom logging (see Apache mod_log_config) on quux-foo.com so that X-Forwarded-For is logged instead of the (default) Remote-Addr. Otherwise, the logs on quux-foo will show that *all* requests come from example.com, and you will not be able to get meaningful application server logfile analysis using that data.
Jim
i rewrote the .htaccess to :
Options +FollowSymLinks
RewriteEngine on
#
# Prevent .htaccess recursion if index.php is requested
RewriteCond $1 !^index\.php$
# else do the rewrite
RewriteRule (.*) [quux-foo.com...] [R=302,L]
&
Options +FollowSymLinks
RewriteEngine on
#
# Prevent .htaccess recursion if index.php is requested
RewriteCond $1 !^index\.php$
# else do the rewrite
RewriteRule (.*) [quux-foo.com...]
both didnt maintain the http://www.example.com/quux-foo/ in the address bar rather it changed to [quux-foo.com...]
However, a 302 redirect typically says to search engines "Keep the URL you first saw, and index the content under that. Pretend you haven't seen where the redirect pointed to."
is it possible to rewrite to /home/quux-foo/public_html/index.php
i've tried it though but it showed me a 404 error, on checking the logs
[Thu Oct 23 13:07:56 2008] [error] [client 41.222.70.210] File does not exist: /home/example/public_html/quux-foo/home/quux-foo/public_html/index.php
(.*) rule is in the root of the site, all requests for robots.txt, stylesheet files, bot ID files ( for webmastertools etc) and images will also be sucked into that rule. The server location only needs to specify the parts that could be addressed from the outside world (i.e. omit the
/home/quux-foo/public_html part). [jd posted at the same time, with corrected code]