Forum Moderators: phranque

Message Too Old, No Replies

Catch all Redirection - Not working

.htaccess problem on catch all php script

         

kenchix1

9:42 am on Mar 24, 2006 (gmt 0)

10+ Year Member



My website previously has 2 domain names, domain1 and domain2 where domain1 is the primary domain and domain2 is just parked to domain1.

I allow users to have their own username as a subdomain and I use PHP script, mypage.php, to validate if a user is allowed to use the subdomain feature.

This PHP script search the database and if the user (the subdomain) is allowed, it will redirect the user to another page (PHP)

such as user1.domain1.com will be redirected to
www.domain1.com/index.php?param1=1&param2=user1_id

everything is working fine until I added a new domain name and I also want to enable the catch all subdomain feature to the new domain (domain3). worst, it doesn't redirect anything at all. It just go to the main page whatever subdomain you type.

this is my .htaccess file :

RewriteEngine on
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.domain1\.com
RewriteRule (.*) [%1.domain1.com...] [R=301,L]
RewriteCond %{HTTP_HOST} ^([^.]+)\.www\.domain3\.com
RewriteRule (.*) [%1.domain3.com...] [R=301,L]

#

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain1\.com [NC]

RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain2\.com [NC]

RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain3\.com [NC]

RewriteRule \.(jpe?g¦gif¦png¦bmp)$ - [F,NC]

#

RewriteCond %{REQUEST_URI}!^/mypage\.php

RewriteCond %{HTTP_HOST}!^www\.domain1\.com

RewriteCond %{HTTP_HOST} ^([^.]+)\.domain1\.com

RewriteCond %{HTTP_HOST}!^www\.domain3\.com

RewriteCond %{HTTP_HOST} ^([^.]+)\.domain3\.com

RewriteRule .* /mypage.php?%1 [L]

------- end

it seems .htaccess is doing nothing.

aside from that, I need to enable allow several sites to read images from domain1.com, what should I put in the .htaccess to allow otherdomain1 and otherdomain2 to read and load the images from domain1?

I can't use the Cpanel hotlink proctection because everytime I enable it, it mess with the .htaccess.

Thank you very much in advance.

jdMorgan

12:34 am on Mar 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I suggest you disable all the code you don't need right now for testing, and then test again. It is not clear exactly what your problem is (we don't know your site, so the description is confusing). So if you simplify the problem and ask again, you'll probably get more useful responses.

Jim