Lerp
Lerp

Reputation: 3127

mod_rewrite logs show what's expected but still get 404?

I am trying to redirect the following from my user directory the follow:

/              > index.php?module=home
/MODULE/       > index.php?module=MODULE
/MODULE/ACTION > index.php?module=MODULE&action=ACTION

These are my rules:

RewriteEngine On

# Rewrite to home page.
#   Input:
#   Output: index?module=home
RewriteRule ^$ index.php?module=home [L,QSA,NC]

# Redirects to a module
#   Input:  MODULE/
#   Output: index.php?module=MODULE
RewriteRule ^(\w+)/?$ index.php?module=$1 [L,QSA,NC]

# Redirects to a module with the specified action
#   Input:  MODULE/ACTION/
#   Output: index.php?module=MODULE&action=ACTION
RewriteRule ^(\w+)/(\w+)/?$ index.php?module=$1&action=$2 [L,QSA,NC]

Just I am always getting a 404.

The logs show me what I am expecting:

[perdir /home/james/public_html/mysite/] rewrite 'user/login' -> 'index.php?module=user&action=login', referer: http://localhost/~james/mysite/
[perdir /home/james/public_html/mysite/] add per-dir prefix: index.php -> /home/james/public_html/mysite/index.php, referer: http://localhost/~james/mysite/

It's correctly rewriting to the the desired URL and it's adding the user directory so why the 404?


From the access log what file it's failing to find:

"GET /~james/mysite/user/login HTTP/1.1" 404 1130 "http://localhost/~james/mysite/"

Upvotes: 0

Views: 254

Answers (1)

Lerp
Lerp

Reputation: 3127

I fixed it by adding the following:

RewriteBase /~james/mysite/

Weird how it resolves the URL correctly but returns 404. Maybe someone smarter than me could shine more light on the matter.

Upvotes: 1

Related Questions