Welcome! Log In Create A New Profile

Advanced

WordPress 3.0 alpha New .htaccess

Posted by jamesdkirk 
WordPress 3.0 alpha New .htaccess
January 28, 2010 06:39PM
Hey Jim!
Been a long time. Trust you & your's are well. Also trust the forums here haven't driven you over the edge!

So, I thought I'd get a jump on the upcoming release of WordPress 3.0. The importance of this release is the merging of the single site with the multi user site code. Going forward it will all be known as "WordPress" and if you want "Multi Site" capability, you enable the "Network" capabilities.

Challenge is that this requires a replacement of the .htaccess file with one generated by the 3.0 alpha code. I've tried simply moving forward with the existing Nginx WP params configuration file, but get stuck in an endless loop. Was hoping for some guidance in converting the new .htaccess (if you've got the time and it doesn't seem terribly challenging!)

Here it is:
[code]
RewriteBase /

#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>
[/code]

The relevant conf code I use (I'm inserting it into my sites available code as an include:
[code]
# WordPress pretty URLs: (as per dominiek.com)
if (-f $request_filename) {
break;
}
if (-d $request_filename) {
break;
}
rewrite ^(.+)$ /index.php?q=$1 last;


# Enable nice permalinks for WordPress: (as per Yawn.it)
error_page 404 = //index.php?q=$uri;
[/code]

Clearly, there's more with the new release. Argh!

Thanks again if you're able to help. I can see this being a big request if the WP devs don't change it in the installation process. Maybe we can get a working copy here for all the budding NginxERS out there?

Cheers!

~~~~~~~~~~
James D Kirk
jamesdkirk.com
Re: WordPress 3.0 alpha New .htaccess
March 18, 2010 07:01AM
Bump.

I'd also appreciate some help with this. I'll even throw in a $50 award (using Paypal) to the first one that posts a valid nginx rewrite for WP 3.0 :)
Re: WordPress 3.0 alpha New .htaccess
April 13, 2010 07:45AM
May be?

[quote]if (!-e $request_filename ) {
rewrite ^(.*)$ /index.php?q=$1 last;
break;
}[/quote]
Re: WordPress 3.0 alpha New .htaccess
June 19, 2010 12:04PM
this is for me working on wp3

i run it via php-cgi, works sweet.

/etc/nginx/sites-avaible/zakenregister.com:
[code]
server {
listen 80;
server_name zakenregister.com;
access_log /var/log/nginx/zakenregister.access.log;

root /var/www/zakenregister.com/www;

index index.php;

# Wordpress permalinks.
include /etc/nginx/wp-params-lumpini;

location / {
try_files $uri $uri/ @wordpress;
}

location @wordpress {
fastcgi_pass unix:/var/run/php-fastcgi/php.sock;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_NAME /index.php;
}

location ~ \.php$ {
try_files $uri @wordpress;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php-fastcgi/php.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;

}

}
[/code]

/etc/nginx/wp-params-lumpini;
[code]
# if the requested file exists, return it immediately
if (-f $request_filename) {
break;
}

set $supercache_file '';
set $supercache_uri $request_uri;

if ($request_method = POST) {
set $supercache_uri '';
}

# Using pretty permalinks, so bypass the cache for any query string
if ($query_string) {
set $supercache_uri '';
}

if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache_uri '';
}

# if we haven't bypassed the cache, specify our supercache file
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}

# only rewrite to the supercache file if it actually exists
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}

# all other requests go to Wordpress
try_files $uri $uri/ index.php;
[/code]

/etc/init.d/php-fastcgi
[code]
BIND_DIR=/var/run/php-fastcgi
BIND="$BIND_DIR/php.sock"
USER=www-data
PHP_FCGI_CHILDREN=8
PHP_FCGI_MAX_REQUESTS=1000

PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0

start() {
echo -n "Starting PHP FastCGI: "
mkdir $BIND_DIR
chown -R $USER $BIND_DIR
start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
RETVAL=$?
echo "$PHP_CGI_NAME."
}
stop() {
echo -n "Stopping PHP FastCGI: "
killall -q -w -u $USER $PHP_CGI
RETVAL=$?
rm -rf $BIND_DIR
echo "$PHP_CGI_NAME."
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: php-fastcgi {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
[/code]
Re: WordPress 3.0 alpha New .htaccess
June 19, 2010 12:06PM
if this works and you really want to donate, then please donate at nginx, they desirve it ;)

grts,

eaonflux
Re: WordPress 3.0 alpha New .htaccess
June 19, 2010 12:08PM
oh if you have custom htacces rules, out them at the end of this file:/etc/nginx/wp-params-lumpini;

ofcourse your paths are different then mine so change them accordenlly to yours...
Re: WordPress 3.0 alpha New .htaccess
June 19, 2010 12:40PM
4 months later... :)

Here's the necessary rewrite in nginx, for WordPress 3.0 with Multi-Site:

rewrite ^.*/files/(.*) /wp-includes/ms-files.php?file=$1;

if (!-e $request_filename) {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+?(/.*\.php)$ $1 last;
rewrite ^ /index.php last;
}
Re: WordPress 3.0 alpha New .htaccess
September 09, 2010 09:36AM
sulo, thank you for your rewrite rules. they work perfectly :)

i want to exchange the subdirectories for real domains.
accessing a wordpress instance not via http://domain.tld/wpsite but via http://wpsite.tld)
unfortunately i am kind of lost with the rewrite rules.

my general config looks like this http://pastebin.com/beufxpih

how do i have to change the rewrite rules so they match a wordpress site?


offtopic:
i played a bit with nginx around and set the server config for wpsite.tld to the same rules as domain.tld (http://pastebin.com/bRsBaBvg)
when i accessed wpsite.tld i was redirected to domain.tld. why is that happening? http://pastebin.com/RCsxwzDd

as you can see i am using debian 5.0 with nginx 0.6.32 and php5.3.3
Re: WordPress 3.0 alpha New .htaccess
September 10, 2010 02:47AM
If you want to use real domains instead of sub domains/directories, you should use the WordPress domain mapping plugin:

http://plugins.svn.wordpress.org/wordpress-mu-domain-mapping/trunk/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 165
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready