nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Feedback on WP Error404, url rewriting

This is a discussion on Feedback on WP Error404, url rewriting within the Web servers forums, part of the Mastering Servers category; Hello I would like to have feebacks, from people who are using this rewriting Lighttpd and wordpress setup clean SEO ...


Go Back   nixCraft Linux Forum > Mastering Servers > Web servers

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-24-2008, 03:07 PM
Junior Member
User
 
Join Date: May 2008
My distro: Debian
Posts: 9
Rep Power: 0
mumuri is on a distinguished road
Question Feedback on WP Error404, url rewriting

Hello

I would like to have feebacks, from people who are using this rewriting
Lighttpd and wordpress setup clean SEO friendly URLs


Is there some problemes with indexation in search engines (indeed the tip is using an error redirection to do the rewrite),


thanks in advance

Mumuri
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-24-2008, 06:03 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Any distro with shell
Posts: 917
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

I'm using lighttpd for cyberciti.biz and there is no problem. Here is how you can verify it for yourself:

Code:
curl -I http://www.cyberciti.biz/tips/lighttpd-and-wordpress-setup-clean-seo-friendly-urls.html
Output:
Code:
HTTP/1.1 200 OK
X-Pingback: http://www.cyberciti.biz/tips/xmlrpc.php
Content-Type: text/html; charset=UTF-8
Date: Sat, 24 May 2008 12:31:00 GMT
Server: lighttpd (Red Hat)
Now let us try 404 stuff:
Code:
curl -I http://www.cyberciti.biz/tips/foo.html
Output:
Code:
HTTP/1.1 404 Not Found
X-Pingback: http://www.cyberciti.biz/tips/xmlrpc.php
Content-Type: text/html; charset=UTF-8
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Last-Modified: Sat, 24 May 2008 12:32:13 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Date: Sat, 24 May 2008 12:32:13 GMT
Server: lighttpd (Red Hat)
Keep in mind, you need to create a 404.php error template file under wp-content/themese/name/404.php.
HTH
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #3 (permalink)  
Old 05-24-2008, 06:20 PM
Junior Member
User
 
Join Date: May 2008
My distro: Debian
Posts: 9
Rep Power: 0
mumuri is on a distinguished road
Default

ok perhaps i didn't understand everything (i m not using this tips for a word pres

here is a test, i ve set up an 404 pages with
Code:
ErrorDocument 404 /mypage.php
in it

now i create a dummy url like this

http://shopog.com/seo-test-error-document.html

Code:
 curl http://shopog.com/seo-test-error-document.html -I
HTTP/1.1 404 Not Found
Date: Sat, 24 May 2008 12:44:44 GMT
Server: Apache
X-Powered-By: PHP/4.4.8
Vary: Host
Content-Type: text/html

which is quite logical:
wrong url ---> 404 error --> redirection to mypage.php --> send page to browser

So if i look at your first test

curl -I ht

tp://www.cyberciti.biz/tips/lighttpd-and-wordpress-setup-clean-seo-friendly-urls.html
what does it mean ?

the only solution i see to do that is that the header is changed in the php file

wrong url ---> 404 error --> redirection to mypage.php --> 200 ok ---> send page to browser

where 200 ok is added directly in the php file

will test that

thanks
Reply With Quote
  #4 (permalink)  
Old 05-24-2008, 06:25 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Any distro with shell
Posts: 917
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

This hack is wordpress specific ONLY. Wordpress has built in support for modifying headers for 200 / 404 status code and templates are designed for the same. For your custom made apps or any other open source software (other than WP) I recommend mod_rewrite.

HTH
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #5 (permalink)  
Old 05-24-2008, 06:25 PM
Junior Member
User
 
Join Date: May 2008
My distro: Debian
Posts: 9
Rep Power: 0
mumuri is on a distinguished road
Default

ok i set up this
mypage.php
Code:
<?php
header("HTTP/1.1 200 OK",true,200);
?>
hello world, postnuke
Code:
~# curl http://shopog.com/mypage.php -I
HTTP/1.1 200 OK
Date: Sat, 24 May 2008 12:52:58 GMT
Server: Apache
X-Powered-By: PHP/4.4.8
Vary: Host
Content-Type: text/html

~# curl http://shopog.com/seo-test-error-document.html -I
HTTP/1.1 404 Not Found
Date: Sat, 24 May 2008 12:53:04 GMT
Server: Apache
X-Powered-By: PHP/4.4.8
Vary: Host
Content-Type: text/html
so my theory is bad ^^

why a 200ok is send even if it s a 404 ?

will look at wordpress error file

EDIT : i ve look and extrated all redirection stuff of wp, then i created this file
Code:
<?php
function absint( $maybeint ) {
	return abs( intval( $maybeint ) );
}
function get_status_header_desc( $code ) {
	global $wp_header_to_desc;

	$code = absint( $code );

	if ( !isset( $wp_header_to_desc ) ) {
		$wp_header_to_desc = array(
			100 => 'Continue',
			101 => 'Switching Protocols',

			200 => 'OK',
			201 => 'Created',
			202 => 'Accepted',
			203 => 'Non-Authoritative Information',
			204 => 'No Content',
			205 => 'Reset Content',
			206 => 'Partial Content',

			300 => 'Multiple Choices',
			301 => 'Moved Permanently',
			302 => 'Found',
			303 => 'See Other',
			304 => 'Not Modified',
			305 => 'Use Proxy',
			307 => 'Temporary Redirect',

			400 => 'Bad Request',
			401 => 'Unauthorized',
			403 => 'Forbidden',
			404 => 'Not Found',
			405 => 'Method Not Allowed',
			406 => 'Not Acceptable',
			407 => 'Proxy Authentication Required',
			408 => 'Request Timeout',
			409 => 'Conflict',
			410 => 'Gone',
			411 => 'Length Required',
			412 => 'Precondition Failed',
			413 => 'Request Entity Too Large',
			414 => 'Request-URI Too Long',
			415 => 'Unsupported Media Type',
			416 => 'Requested Range Not Satisfiable',
			417 => 'Expectation Failed',

			500 => 'Internal Server Error',
			501 => 'Not Implemented',
			502 => 'Bad Gateway',
			503 => 'Service Unavailable',
			504 => 'Gateway Timeout',
			505 => 'HTTP Version Not Supported'
		);
	}

	if ( isset( $wp_header_to_desc[$code] ) )
		return $wp_header_to_desc[$code];
	else
		return '';
}

function status_header( $header ) {
	$text = get_status_header_desc( $header );

	if ( empty( $text ) )
		return false;

	$protocol = $_SERVER["SERVER_PROTOCOL"];
	if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
		$protocol = 'HTTP/1.0';
	$status_header = "$protocol $header $text";
	if ( function_exists( 'apply_filters' ) )
		$status_header = apply_filters( 'status_header', $status_header, $header, $text, $protocol );

	if ( version_compare( phpversion(), '4.3.0', '>=' ) )
		return @header( $status_header, true, $header );
	else
		return @header( $status_header );
}
	header('Content-Type: text/plain');
	status_header('200');
	exit;
?>
the result are the same, so i think there is something in the server configuration who doesn't allow this

will look at that

Last edited by mumuri; 05-24-2008 at 06:53 PM.
Reply With Quote
  #6 (permalink)  
Old 05-24-2008, 07:10 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Any distro with shell
Posts: 917
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You also need server.errorfile-prefix lighttpd.conf to get 200 and 404 and other code correctly :
Code:
server.errorfile-prefix = "/home/lighttpd/errors/status-"
Now create static pages for your error handling in directory
/home/lighttpd/errors. Based on the above entry you must name your files status-(status-code).html
Code:
/home/lighttpd/errors/status-404.html
/home/lighttpd/errors/status-500.html
/home/lighttpd/errors/status-501.html
You can create custom pages for any error status code.
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
  #7 (permalink)  
Old 05-24-2008, 07:13 PM
Junior Member
User
 
Join Date: May 2008
My distro: Debian
Posts: 9
Rep Power: 0
mumuri is on a distinguished road
Default

i did my test on an apache ^^

ok that works, i test the above script on an other server, and it s worked
Reply With Quote
Reply

Bookmarks

Tags
404 , error404 , lighttpd , linux , seo


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +5.5. The time now is 01:36 AM.


Powered by vBulletin® Version 3.7.2 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36