RewriteRule: content ok but 404 returned in HTTP :




I have very strange problem; I changed structure of my site and used WordPress now to serve all pages on site.

One of the pages was:

Now, that content is served now by calling:

I wanted to preserve nice URL’s, so I created following section in .htaccess file:

[code]#BEGIN /english section

RewriteEngine On
RewriteBase /

RewriteRule ^english$ /english/ [R=301]
RewriteRule ^english/index.php$ /english/ [R=301]
RewriteRule ^english/index.html$ /english/ [R=301]
RewriteRule ^english/$ /index.php?p=21 [L]

#END /english section [/code] Now, behaviour is very strange:
  • if you open in browser you WILL get content BUT you will also get HTTP/1.x 404 code in header :frowning: (you need some tool which reports HTTP header info) which means “Page not found”.

Can I somehow force Apache not to emit 404 code, i.e. to check FIRST if there is RewriteRule for given URL and ONLY if there is no such rule to emit 404?



hmm, I did not get the 404 header for either link. When I purposely typed in a missing page I got your custom 404 in your wordpress template, so everything seems to work.

Wordpress will actually create a valid htaccess rewrite rule for you, you can specify exactly how you want your pages to appear. It automatically updates (must be chmodded 777) the htaccess page as your change it.


Try to use any tool which obeys HTTP header codes (for example wget) or to use LiveHeaders for FireFox - you will get 404 not found and wget won’t even retrieve page; ordinary browser will display page, but 404 will be in HTTP header.

Here are details:

G:\Work\>wget --22:11:17-- => `index.html' Resolving Connecting to||:80... connected. HTTP request sent, awaiting response... 404 Not Found 22:11:18 ERROR 404: Not Found.



hmm, ok

[quote]Response Headers -

Date: Wed, 08 Mar 2006 21:12:08 GMT
Server: Apache/1.3.33 (Unix) DAV/1.0.3 mod_fastcgi/2.4.2 mod_gzip/ PHP/4.4.2 mod_ssl/2.8.22 OpenSSL/0.9.7e
X-Powered-By: PHP/4.4.2
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

404 Not Found[/quote]
wow, that IS weird.

I’m no rewrite expert. I use the built-in wordpress rewrite and it doesn’t throw this error (just checked).


Well it IS weird :slight_smile:

I have multiple WordPress installations on site, and only this one, which hosts root files/pages experience this problem; other URL’s do just fine (no 404’s).


The original URL returns a 301, but look where it’s sending me:

$ lynx -head -dump HTTP/1.1 301 Moved Permanently Date: Wed, 08 Mar 2006 21:53:20 GMT Server: Apache/1.3.33 (Unix) DAV/1.0.3 mod_fastcgi/2.4.2 mod_gzip/ PHP /4.4.2 mod_ssl/2.8.22 OpenSSL/0.9.7e Location: Connection: close Content-Type: text/html; charset=iso-8859-1
The URL in the Location: header is where I’m being redirected to. Loading this URL results in the 404. Note the X-Pingback header, which tells us that WordPress is serving up this error:

$ lynx -head -dump HTTP/1.1 404 Not Found Date: Wed, 08 Mar 2006 21:55:00 GMT Server: Apache/1.3.33 (Unix) DAV/1.0.3 mod_fastcgi/2.4.2 mod_gzip/ PHP /4.4.2 mod_ssl/2.8.22 OpenSSL/0.9.7e X-Pingback: X-Powered-By: PHP/4.4.2 Connection: close Content-Type: text/html

If you want useful replies, ask smart questions.


Sorry, I was just experimenting and you got in the middle of it :frowning: Try again please, I reverted old .htaccess now (you will get 404)