Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Just moved to shared hosting on GoDaddy and Im trying to get my .htaccess rules working.

Heres what I have:

ErrorDocument 404 /error.php
Options FollowSymLinks

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www\.mydomain\.org$
RewriteRule ^(.*)$$1 [R=301,L]

RewriteRule ^view/(\w+)$ viewitem.php?itemid=$1 [R=301,L]
RewriteRule ^category/(\w+)$ viewcategory.php?tag=$1 [R=301,L]

RewriteRule ^faq$ faq.php
RewriteRule ^about$ about.php
RewriteRule ^contact$ contact.php
RewriteRule ^submit$ submit.php
RewriteRule ^contactmsg$ handler-contact.php

All the pages @ the root of the domain seem to be working i.e, are working.

But whenever I try, I get a 404. How can I fix my .htaccess to obey these rules that are more than 1 level deep?


EDIT: I have fixed the rules by changing them to the following:

RewriteRule ^view/(.*)$ viewitem.php?itemid=$1
RewriteRule ^category/(.*)$ viewcategory.php?tag=$1

Can anyone confirm/deny that this is the proper way to fix this?

share|improve this question
up vote 1 down vote accepted

The new way you're doing it (with (.*)) is correct.

share|improve this answer
Ok cool. Thats just a wildcard for everything Im assuming? What did (\w+) technically do before? – barfoon Jun 3 '10 at 18:30
.* means match anything. Specifically, . means "any character", and the * means 0 or more of those. \win perl-compatible regexes (which Apache should use there) means alphanumeric or "_". So, maybe your categories have some other character in them? Spaces? – Bill Weiss Jun 3 '10 at 18:34
Oh ok thanks for the clarification Bill. Categories dont have spaces, dont know why they wouldnt be caught there. – barfoon Jun 3 '10 at 19:37
What does a category look like? Can you show the logs from one? – Bill Weiss Jun 3 '10 at 20:18
A category is just a string with no spaces - e.g. "friends", "family", "misc", "health". Any ideas? – barfoon Jun 4 '10 at 14:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.