I want to set a rule in .htaccess if I enter in the url www.mydomain.com/compare.php set 'public\_html' as root otherwise anything come in the url set root as 'public' folder. 

```
RewriteRule ^(?!compare-source.php).*)$ public/$1 [L]

```

I want to achieve following result.

if url is **www.mydomain.com/compare.php** hit following file.

```
public_html/compare.php

```

if urls are **www.mydomain.com/** OR **www.mydomain.com/home** etc hit following file.

```
public_html/public/index.php

```

I am weak in regex and in these apache rules always :-( can someone give me the solution with good description?

Your answers are welcome, please can you describe how this crazy things work in detail. Thanks.