Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

This is an example of an error in out log file:

 File does not exist: /var/www/website/female, referer: http://www.website.com/female/dresses/A-Dress-Black

"/female" doesn't exist, because we use friendly urls via our .htaccess file which looks like this:

RewriteEngine On # Turn on the rewriting engine
RewriteBase /
RewriteCond %{http_host} !^www.website.com$ [nc]
RewriteRule ^(.*)$ http://www.website.com/$1 [r=301,nc,L]
RewriteRule ^News/?$ news.php [NC,L]
RewriteRule ^About/?$ about.php [NC,L]
RewriteRule ^Contact/?$ contact.php [NC,L]
RewriteRule ^Sign-In/Create-Account?$ sign_up_in.php [NC,L]
RewriteRule ^Logout?$ sign_up_in.php?l=1 [NC,L]
RewriteRule ^Your-Bag?$ your_bag.php [NC,L]
RewriteRule ^Help?$ help.php [NC,L]
RewriteRule ^Profile?$ profile.php [NC,L]
RewriteRule ^Create-Profile?$ profile_create.php [NC,L]
# ITEM
RewriteRule ^([A-Za-z-]+)/([A-Za-z-]+)/([A-Za-z0-9-]+)/?$ store_focus.php?sex=$1catName=$2&permalink=$3 [NC,L]
# PAGE
RewriteRule ^([A-Za-z-]+)/([A-Za-z-]+)/page/([0-9]+)/?$ store.php?sex=$1&catName=$2&page=$3 [NC,L]
# CATEGORY
RewriteRule ^([A-Za-z-]+)/([A-Za-z-]+)/?$ store.php?sex=$1&catName=$2 [NC,L]
# SEX
RewriteRule ^([A-Za-z-]+)/?$ store.php?sex=$1 [NC,L]

Every request for a page results in an error even though the site works fine. Has anyone encountered this before?

Thanks!

Beren

share|improve this question
    
I still haven't got to the bottom of this... really annoying! –  Samuurai Jan 18 '11 at 10:12
1  
Asked April 2010 .. Last answer Feb 2011, OP's last comment dated March 2011 .. and still no solution? Doh. 1) There is missing & in ITEM rule: store_focus.php?sex=$1catName= should be store_focus.php?sex=$1&catName= 2) Individual pages rewrite rules have missing / before ?: ^Profile?$ should be ^Profile/?$ –  LazyOne Jul 9 '11 at 10:16
add comment

migrated from serverfault.com Jul 9 '11 at 0:42

This question came from our site for professional system and network administrators.

5 Answers

You are trying to match a path that starts with a letter or number, but it starts with a '/'. Your rules should be something like

RewriteRule ^/([A-Za-z0-9-])/...$      ...

Alos, do you have access to the logs? If so, enable the logs for mog_rewrite

RewriteLog /some/path
RewriteLogLevel 3
share|improve this answer
    
Unfortunately It gives me an error when I add a "/". Do you really need the "/" if you have RewriteBase = "/" ---- The requested URL /female/just-arrived/page/1 was not found on this server. –  Samuurai Apr 15 '10 at 9:44
    
I do not think RewriteBase does what you think... Try remove it. –  Dan Andreatta Apr 15 '10 at 10:17
    
No difference, damn! –  Samuurai Apr 15 '10 at 11:03
    
Edited my answer with more ideas –  Dan Andreatta Apr 15 '10 at 11:49
    
Ah good idea.. didn't realise you could log rewrites. I've got the log here: 79.125.18.68/rwlog.txt Just trying to make some sense of it. –  Samuurai Apr 15 '10 at 11:59
show 2 more comments

If your Rewrite rules are in an .htaccess file, you need to have at least

AllowOverride FileInfo

in your apache configuration.

And you also need to have

Options FollowSymLinks

If your server configuration has

AllowOverride FileInfo Options

(or AllowOverride All) then you can also add Options FollowSymlinks to the .htaccess file.

share|improve this answer
    
I don't use .htacces..All options are set in the VHost. –  Samuurai Mar 3 '11 at 13:20
add comment

There is a decent chance that the error doe not come from the page itself but rather from an element on the page.

Example: <img src="img/bla.jpg"/> would point to /female/dresses/img/bla.jpg instead of /img/bla.jpg.

Because the server first checks for the female folder when it's searching for the bla.jpg, it will never give the error on the element itself

share|improve this answer
    
Thank you! I had the same problem and in my case it was because the web browser was searching for the favincon.png file with a relative path. –  francadaval Aug 9 '13 at 9:58
add comment

Been a while since I used Apache or wrote any Rewrite Rules, but are trying to match any number of A-Za-z and - do you not need to escape the last - "-"

or is the last - doing something special I would guess that's your problem if your trying to match -'s

# ITEM
RewriteRule ^([A-Za-z-]+)/([A-Za-z-]+)/([A-Za-z0-9-]+)/?$ store_focus.php?sex=$1catName=$2&permalink=$3 [NC,L]
share|improve this answer
    
Hmm, that's not it. The hyphen can be anywhere outside of a range, unescaped. –  Samuurai Apr 14 '10 at 14:18
    
Sometimes the log just looks like this: [Wed Apr 14 15:18:37 2010] [error] [client 81.138.14.83] File does not exist: /var/www/website/female –  Samuurai Apr 14 '10 at 14:19
    
another thing I notice is that you are looking for something that begins with a letter or - <pre>^([A-Za-z-]+)</pre> after a quick glance as the rewrite docs at httpd.apache.org they look like that all start by looking for a / the one after the domain name. You are not trying to find this first / –  Alistair Prestidge Apr 14 '10 at 14:37
    
so you think it should be RewriteRule ^/([A-Z......... ? –  Samuurai Apr 14 '10 at 15:33
add comment

I have the same problem. A work-around is to create the directory that is reported to be missing.

mkdir /var/www/website/female

Once it gets past the directory check, the RewriteRule will probably work. It's a mystery to me why it first checks the existence of the directory.

share|improve this answer
add comment

Your Answer

 
discard

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