0

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 Answers1

0

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]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Not Found The requested URL / was not found on this server. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request. – ashishchaudhary Nov 26 '14 at 08:50
  • can you check anubhava what's the problem. – ashishchaudhary Nov 26 '14 at 09:01
  • i have made some changes to your htaccess now it's working, but now it is in the form of this. http://xyz2.com/Delhi%2C+IndiaNoida%2C+Uttar+Pradesh%2C+India.html, please see my actual post for changes i have made. i want to remove %2C+ to -, how can i do this – ashishchaudhary Nov 26 '14 at 11:12
  • yes because the data contains comma and these are dynamic url – ashishchaudhary Nov 26 '14 at 11:25
  • I am not allowed to provide long support using comments section but if data in database contains comma then you must keep them as is. – anubhava Nov 26 '14 at 11:34
  • One more thing you can do is to mark this as accepted (since this worked for you) and open a new question to convert `%2C` to something else and I will provide a separate answer for that. – anubhava Nov 26 '14 at 11:38