Web Hosting Talk







View Full Version : Help with Malfunctioning .htaccess File


tjmaxwell
08-20-2007, 11:59 AM
Hi all,

My site is informational as well as a store. I'm using CuteNews as a news script for the main site, and a modification that that uses ModRewrite to change news URLs to the title of the article. I'm also using a shopping cart package that uses ModRewrite to rewrite store pages to search engine friendly URLs. I'm not really that knowledgeable with .htaccess files, and I'm having a problem with mine.

Basically, whenever someone visits a link like "domain.com/catalog/" or, in other words, linking directly to a category folder, they are just taken to (broken) version of my home page (home.php). I have index.php files set up in those directories, but something about my .htaccess is causing a conflict and redirecting all category folders. I hope this makes sense.

Anyway, here is my .htaccess code. I don't really understand it all and I know some might not be necessary, so if you could help me, I'd really appreciate it. Thanks a lot in advance!


DirectoryIndex /home.php
ErrorDocument 404 /404.php

# NEWS SCRIPT RELATED
RewriteEngine On
RewriteBase /
RewriteRule ^post/(.*).html(.*)$ home.php?subaction=showfull&url=$1$2 [L,NC]
RewriteRule ^postpage/(.*).html(.*)$ home.php?start_from=$1$2 [L,NC]
RewriteRule ^comments/(.*).html(.*)$home.php?subaction=showcomments&url=$1$2 [L,NC]
RewriteRule ^commentspage/(.*)/(.*).html(.*)$index.php?comm_start_from=$1&subaction=showcomments&url=$2$3 [L,NC]
RewriteRule ^archiveindex/(.*).html(.*)$home.php?archive=$1&subaction=list-archive$2 [L,NC]
RewriteRule ^archive/(.*).html(.*)$home.php?subaction=showfull&url=$1$2 [L,NC]
RewriteRule ^archivepage/(.*)/(.*).html(.*)$home.php?start_from=$2&archive=$1&subaction=list-archive$3 [L,NC]

# REWRITE RULES
Options +SymlinksIfOwnerMatch -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST}!^www\.domain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
rewriteRule (.*) http://www.domain.com/$1 [R=301,L]

# STORE RELATED

RewriteBase /
RewriteRule ^([^/]*/)?[^/]+p[-_]?([0-9]+)\.html$$1index.php?target=products&product_id=$2[L]
RewriteRule ^([^/]*/)?[^/]+c[-_]?([0-9]+)([-_]sort[-_]([a-z0-9_]+)[-_]order[-_]([a-z0-9_]+))?([-_]page-([a-z0-9_]+))?\.html$

$1index.php?target=categories&category_id=$2&sort_by=$4&sort_order=$5&page=$7[L]
RewriteRule ^([^/]*/)?[^/]+a[-_]?([0-9]+)\.html$ $1index.php?target=pages&page_inner_id=$2[L]
RewriteRule ^([^/]*/)?[^/]+t[-_]?([0-9]+)\.html$ $1index.php?target=topics&topic_id=$2[L]
RewriteRule ^([^/]*/)?[^/]+m[-_]?([0-9]+)([-_]sort[-_]([a-z0-9_]+)[-_]order[-_]([a-z0-9_]+))?([-_]page-([a-z0-9_]+))?\.html$

$1index.php?target=manufacturers&manufacturer_id=$2&sort_by=$4&sort_order=$5&page=$7[L]
RewriteRule ^([^/]*/)?form[-_]?([a-z0-9_]+)[-_]?(sent)?\.html$ $1index.php?target=forms&name=$2&mode=$3[L]
RewriteRule ^([^/]*/)?manufacturers\.html$ $1index.php?target=manufacturers[L]
RewriteRule ^([^/]*/)?catalog\.html$ $1index.php?mode=catalog[L]
RewriteRule ^([^/]*/)?index\.html$ $1index.php[L]

# GENERAL

RewriteCond %{HTTP_REFERER}!^http://(.+\.)?domain\.com/ [NC]
RewriteCond %{HTTP_REFERER}!^https://(.+\.)?domain\.com/ [NC]
RewriteCond %{HTTP_REFERER}!^$
RewriteRule .*\.(jpe?g¦gif¦bmp¦png¦mid¦mp3)$ - [F]

</IfModule>

E-Visionz
08-21-2007, 08:37 AM
Have you tried to create a blank .htaccess file in the catalog directory?
This might overwrite DirectoryIndex /home.php