.htaccess url rewriting for addon domains

294 views Asked by At

I have a web hosting that is running multiple website. Suppose i have xyz.com that is the main website under this other websites are running as addon domains.

Like i have another website that is xyz2.com that is addon domain. There is folder created corresponding to the domain xyz2.com.

Now the problem is i want to add some .htaccess rule there is no rule defined for root website. I want to add rule only for xyz2.com that is addon domain.

i have placed my .htaccess to the folder xyz2.com. here is what i wrote.

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^(www\.)?xyz2.com\.com$ [NC]

RewriteCond %{THE_REQUEST} /find\.php\?source=([^\s&]+)&destination=([^\s&]+) [NC]
RewriteRule ^ %1-%2.html? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\s]+)-([^\s]+)?.html$ find.php?source=$1&destination=$2 [L,QSA]

This is not working i have searched a lot on google for this problem but no suggestions is working. Please help me to short out this problem.

1

There are 1 answers

6
anubhava On

You can try this rule in

RewriteEngine On
RewriteBase /xyz2.com/

RewriteCond %{HTTP_HOST} !^(www\.)?xyz2\.com$ [NC]
RewriteRule ^ - [L,R=404]

RewriteCond %{THE_REQUEST} /find\.php\?source=([^\s&]+)&destination=([^\s&]+) [NC]
RewriteRule ^ %1/%2? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ find.php?source=$1&destination=$2 [L,QSA]