Link to home
Start Free TrialLog in
Avatar of killer455
killer455

asked on

htaccess mod rewrite syntax, newbie help

Basically I am wondering about some syntax issues.  The below htaccess file works fine for me.
However I have seen things written differently elsewhere and am wondering why it matters.

Here are some examples:
I have seen  mydomain\.com and mydomain.com
When do I need to use the "\"?
I have also seen (.*) and then ^(.*), what is the different here?
Also I have seen is there the ending "$" is not included at all, any reason for this?

If you could check the syntax of my code below and suggest changes let me know.

0 RewriteEngine on
1 RewriteCond %{HTTP_HOST} !^www.maindomain.com$ [NC]
2 RewriteCond %{REQUEST_URI} !^/robots\.txt$
3 RewriteRule (.*) http://www.maindomain.com/$1 [R=301]
4
5 #If robots.txt is requested from anything other than maindomain send new txt file.
6 RewriteCond %{HTTP_HOST} !^maindomain\.com
7 RewriteRule ^robots\.txt /robots_noindex.txt [L]
ASKER CERTIFIED SOLUTION
Avatar of CrYpTiC_MauleR
CrYpTiC_MauleR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of CrYpTiC_MauleR
CrYpTiC_MauleR

http://regexlib.com/CheatSheet.htm will give you info on regualr expression syntax