0

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 ^(.*)$ http://mydomain.org/$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 mydomain.org/faq, mydomain.org/about are working.

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

Thanks,

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?

barfoon
  • 750
  • 3
  • 14
  • 29

1 Answers1

1

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

Bill Weiss
  • 10,782
  • 3
  • 37
  • 65
  • Ok cool. Thats just a wildcard for everything Im assuming? What did (\w+) technically do before? – barfoon Jun 03 '10 at 18:30
  • `.*` means match anything. Specifically, `.` means "any character", and the `*` means 0 or more of those. `\w`in 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 03 '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 03 '10 at 19:37
  • What does a category look like? Can you show the logs from one? – Bill Weiss Jun 03 '10 at 20:18
  • A category is just a string with no spaces - e.g. "friends", "family", "misc", "health". Any ideas? – barfoon Jun 04 '10 at 14:50
  • From some googling around, I see that `^view/([\w]+)$` might work for you. Give it a shot? I don't know why you would need to put `[]` around the character class... – Bill Weiss Jun 04 '10 at 15:48
  • Your latest comment didnt work, I think ill just stick to (.*)$ – barfoon Jun 04 '10 at 16:32