Forum Moderators: phranque
My htaccess file:
I made custom 404+403
A force-WWW
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.xx [NC]
RewriteRule ^(.*) [domain.xx...] [R=permanent,L]
..and that is the problem - my redirect to home.html. I've looked all over and tested several tips I've found - all gives me a 500 misconfiguration.
I'd like to put in something like:
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain\.xx(/)?.*$ [NC]
"RewriteRule them from index ---> /home.html"
...the then back to index...
I also tested a javascript tht does the same thing just to prevent the Error500, but then I had a loop... (was just loading on)
I hope you understand my explanation? :)
Is there a workaround? Is this possible? ..without removing the 403 page and the force-www?
Thanks in Advance!
I'd really like this one to work.
However, the details here as to which page is on which domain are sketchy and unclear, so that's all I can offer on that subject.
Your best bet is to put up a "lobby" page and let the user select which site is desired; Any automation based on %{HTTP_REFERER} will fail as often as not, because many visitors requests will not provide a referrer, either because their "internet security" software blocks it (and perhaps without their knowledge), or because they are behind corporate or ISP caching proxies (e.g. All of AOL), which also will not provide a referrer. Referrers can also be easily spoofed. Basically, the HTTP referrer is almost completely unreliable.
Jim
Here's the full htaccess-file:
<Files .htaccess>
order allow,deny
deny from all
</Files>
AddHandler server-parsed .html
Options All -Indexes +FollowSymLinks
# stop hot-linking
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?sub.example\.com(/)?.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(www\.)?another\.site\.com(/)?.*$ [NC]
RewriteRule .*\.(jpg¦gif¦png)$ - [F,NC]
# force-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*) http://www.example.com/$1 [R=permanent,L]
# sub domain
RedirectMatch permanent ^/sub/.*$ [sub.example.com...]
ErrorDocument 403 /403.html
ErrorDocument 404 /404.html
# # # # #
Navigation today:
example.com/ (index.html) = "lobby-page" with 2 links to..
-» example.com/folder/file1.html
-» example.com/folder/file2.html
My idea is to get a clearer picture who's who sort of. By giving each on their own index as in example.com/(index.html) and company2 sub.example.com/index.html) but to catch incomers to this "lobby-page".
Hope this cleared up the sketch. :)
I start to belive I have to give up the custom 403 page to get this work, but it would be nice to keep that on in there.
Thanks
/Eric
I would advise, however, that you don't mix mod_alias and mod_rewrite directives. If you do, you won't have control of which executes first on any given server. I'd recommend replacing:
# sub domain
RedirectMatch permanent ^/sub/.*$ http://sub.example.com/$1
# sub domain
RewriteRule ^sub/(.*)$ http://sub.example.com/$1 [R=301,L]
The custom 403 and 404 pages should have nothing to do with the rest of this.
Jim
The htaccess file works fine as it is now. No chains and it loads as I want it so far. My problem is that I do get the 500Error and a loop when I want to try making an additional redirect to the home.html (the "lobby-page") Like I wrote in my first post:
###
I'd like to put in something like:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?domain\.xx(/)?.*$ [NC]
"RewriteRule them from index ---> /home.html"
...the then back to index...
###
And all of those different versions I've tried to make it work - that's where it failes.
OK - I'll go back and try this now and see what's happening.
Thanks again.
/Eric