Solved

htaccess mod rewrite syntax, newbie help

Posted on 2004-08-01
2
283 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

Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
Over the last year I have answered a couple of basic URL rewriting questions several times so I thought I might as well have a stab at: explaining the basics, providing a few useful links and consolidating some of the most common queries into a sing…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 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