RewriteRule: content ok but 404 returned in HTTP :

wordpress

#1

Hello.

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:
http://www.vesic.org/english/

Now, that content is served now by calling:

http://www.vesic.org/index.php?p=21

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 http://www.vesic.org/english/ 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?

Regards,
Dejan


#2

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.


#3

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\www.vesic.org>wget http://www.vesic.org/english/ --22:11:17-- http://www.vesic.org/english/ => `index.html' Resolving www.vesic.org... 208.97.139.196 Connecting to www.vesic.org|208.97.139.196|:80... connected. HTTP request sent, awaiting response... 404 Not Found 22:11:18 ERROR 404: Not Found.

Regards,
Dejan


#4

hmm, ok

[quote]Response Headers - http://www.vesic.org/english/

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/1.3.26.1a PHP/4.4.2 mod_ssl/2.8.22 OpenSSL/0.9.7e
X-Pingback: http://www.vesic.org/xmlrpc.php
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).


#5

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).


#6

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

$ lynx -head -dump http://www.vesic.org/english/ 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/1.3.26.1a PHP /4.4.2 mod_ssl/2.8.22 OpenSSL/0.9.7e Location: http://www.vesic.org/english/?p=25 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://www.vesic.org/english/?p=25 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/1.3.26.1a PHP /4.4.2 mod_ssl/2.8.22 OpenSSL/0.9.7e X-Pingback: http://www.vesic.org/xmlrpc.php X-Powered-By: PHP/4.4.2 Connection: close Content-Type: text/html

If you want useful replies, ask smart questions.


#7

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)

Regards,
Dejan