Solved

htaccess mod rewrite syntax, newbie help

Posted on 2004-08-01
2
238 Views
Last Modified: 2010-03-04
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]
0
Comment
Question by:killer455
  • 2
2 Comments
 
LVL 18

Accepted Solution

by:
CrYpTiC_MauleR earned 50 total points
ID: 11692025
the \ means the period afterwards will mean a period character otherwise it will mean ANY character, so you must 'escape' it.

^ means the beggining of the string also $ means the end of the string.
0
 
LVL 18

Expert Comment

by:CrYpTiC_MauleR
ID: 11692028
http://regexlib.com/CheatSheet.htm will give you info on regualr expression syntax
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now