Solved

htaccess mod rewrite syntax, newbie help

Posted on 2004-08-01
2
289 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

631 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