Forum Moderators: phranque

Message Too Old, No Replies

Correct my mod rewrite 404 prob / apache setup?

Mod rewrite 404 prob and apache setup

         

Bean_Boy

10:20 pm on Nov 13, 2005 (gmt 0)

10+ Year Member



Can anyone help me with this please? I am installing article dashboard on my home web server using Apache/1.3.31 (Win32) PHP/4.3.8 Part of the software has a mod rewrite function in the .htaccess file.

Here is the script:

RewriteEngine On
RewriteBase /articledashboard
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R,L]

RewriteRule ^profile\/([^\/]+)/([0-9]+) publicprofile.php?name=$1&id=$2
RewriteRule ^Category/[^\/]+/([0-9]+)/?(.*) index.php?catid=$1&mode=category
RewriteRule ^Article/[^\/]+/([0-9]+)/?(.*) article.php?id=$1&act=$2
RewriteRule ^rss/[^\/]+/([0-9]+) rssarticle.php?id=$1
RewriteRule ^myarticles/(.*)$ index.php?mode=myarticles
RewriteRule ^(.*)topauthorslist/ topauthors.php?orderby=$1&ordertype=$2&namelike=$3&page=$4
RewriteRule ^(.*)popularlist/ populararticles.php?page=$2
RewriteRule ^(.*)searchresult/ indexser.php?page=$2

The problem is that when you click on
http://example.com/articles/index.php and then for example "Wine and Spirits"
The link tries to go to
http://example.com/articledashboard/Category/Wine-and-Spirits/53
yet all one gets is a 404 error page. As other links work, I assume this is a problem with the category rewrite rule.

Any help would be much appreciated. Is it to do with the rewrite rule, or the Apache httpd.conf setup?

[edited by: jdMorgan at 10:45 pm (utc) on Nov. 13, 2005]
[edit reason] No URLs, please. See TOS, [/edit]

jdMorgan

10:48 pm on Nov 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bean_Boy,

There are several things possibly wrong with this, but let's take first things first.

What specific URL-path are you requesting, what do you expect it to be rewritten to, and and what is it actully rewritten to?

Please use example.com if you need to show a domain name, since we don not allow posting of members personal domains on this site.

Jim

Bean_Boy

8:23 pm on Nov 14, 2005 (gmt 0)

10+ Year Member



Sorry about the domain thing. First post and all.

I think I'm talking about (first) this rule not working with my current set up.

RewriteRule ^Category/[^\/]+/([0-9]+)/?(.*) index.php?catid=$1&mode=category

The link on the page points to (or is rewritten to - I don't know)

http://example.com/articledashboard/Category/Food-and-Drink/61

The browser then gives the 404 error.

The same intended page can be arrived at by

http://example.com/articledashboard/index.php?catid=61

with no error.

Hope this explains the problem further. How do I make the rewritten URL go to the correct page? Anymore questions, please let me know.

Regards

jdMorgan

1:39 pm on Nov 15, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It looks to me as though your back-reference in the substitution is wrong, using $1 rather than $2:

RewriteRule ^Category/[^/]+/([0-9]+) index.php?cati[b]d=$2&m[/b]ode=category [L]

Given your example URL, $1 would be "Food-and-Drink," rather than the desired "61".

I also added an [L] flag and removed unnecessary regex to improve efficiency.

Jim

Bean_Boy

7:55 pm on Nov 15, 2005 (gmt 0)

10+ Year Member



Thanks for that suggestion. I've tried replacing the existing line with your suggestion, but unfortunately it has not worked. Any other ideas?