问题:
我正在使用(我认为)一个相当标准的多站点WordPress设置,它使用qTranslate进行国际化。我有一个菜单,生成以下形式的链接:
http://www.example.com/theblog/thepage/?lang=XX
然而,去那里会返回302
,然后重定向到
http://www.example.com/theblog/thepage
没有斜杠且没有查询参数(因此将语言切换为默认值)。
我对mod_rewrite
和WordPress都不是很好,所以如果有人可以帮我调试正在发生的事情,我将不胜感激。我的假设是有一个流氓重定向继续删除斜线;但我无法在.htaccess
中看到任何可以解释它的规则 - 除非WordPress本身就是这样做的,出于某种原因。以下是重写日志所说的内容(为简洁和匿名而编辑):
...[rid#...a0/initial] (3) [perdir /...] add path info postfix: /var/www/wordpress/theblog -> /var/www/wordpress/theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/theblog/thepage -> theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^index\.php$' to uri 'theblog/thepage'
...[rid#...a0/initial] (3) [perdir /...] add path info postfix: /var/www/wordpress/theblog -> /var/www/wordpress/theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/theblog/thepage -> theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^([_0-9a-zA-Z-]+/)?files/(.+)' to uri 'theblog/thepage'
...[rid#...a0/initial] (3) [perdir /...] add path info postfix: /var/www/wordpress/theblog -> /var/www/wordpress/theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/theblog/thepage -> theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^([_0-9a-zA-Z-]+/)?wp-admin$' to uri 'theblog/thepage'
...[rid#...a0/initial] (3) [perdir /...] add path info postfix: /var/www/wordpress/theblog -> /var/www/wordpress/theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/theblog/thepage -> theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^' to uri 'theblog/thepage'
...[rid#...a0/initial] (4) [perdir /...] RewriteCond: input='/var/www/wordpress/theblog' pattern='-f' => not-matched
...[rid#...a0/initial] (4) [perdir /...] RewriteCond: input='/var/www/wordpress/theblog' pattern='-d' => not-matched
...[rid#...a0/initial] (3) [perdir /...] add path info postfix: /var/www/wordpress/theblog -> /var/www/wordpress/theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/theblog/thepage -> theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)' to uri 'theblog/thepage'
...[rid#...a0/initial] (3) [perdir /...] add path info postfix: /var/www/wordpress/theblog -> /var/www/wordpress/theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/theblog/thepage -> theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^[_0-9a-zA-Z-]+/(.*\.php)$' to uri 'theblog/thepage'
...[rid#...a0/initial] (3) [perdir /...] add path info postfix: /var/www/wordpress/theblog -> /var/www/wordpress/theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/theblog/thepage -> theblog/thepage
...[rid#...a0/initial] (3) [perdir /...] applying pattern '.' to uri 'theblog/thepage'
...[rid#...a0/initial] (2) [perdir /...] rewrite 'theblog/thepage' -> 'index.php'
...[rid#...a0/initial] (3) [perdir /...] add per-dir prefix: index.php -> /var/www/wordpress/index.php
...[rid#...a0/initial] (2) [perdir /...] trying to replace prefix /var/www/wordpress/ with /
...[rid#...a0/initial] (5) strip matching prefix: /var/www/wordpress/index.php -> index.php
...[rid#...a0/initial] (4) add subst prefix: index.php -> /index.php
...[rid#...a0/initial] (1) [perdir /...] internal redirect with /index.php [INTERNAL REDIRECT]
...[rid#...68/initial/redir#1] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/index.php -> index.php
...[rid#...68/initial/redir#1] (3) [perdir /...] applying pattern '^index\.php$' to uri 'index.php'
...[rid#...68/initial/redir#1] (1) [perdir /...] pass through /var/www/wordpress/index.php
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/favicon.ico -> favicon.ico
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^index\.php$' to uri 'favicon.ico'
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/favicon.ico -> favicon.ico
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^([_0-9a-zA-Z-]+/)?files/(.+)' to uri 'favicon.ico'
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/favicon.ico -> favicon.ico
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^([_0-9a-zA-Z-]+/)?wp-admin$' to uri 'favicon.ico'
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/favicon.ico -> favicon.ico
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^' to uri 'favicon.ico'
...[rid#...a0/initial] (4) [perdir /...] RewriteCond: input='/var/www/wordpress/favicon.ico' pattern='-f' => not-matched
...[rid#...a0/initial] (4) [perdir /...] RewriteCond: input='/var/www/wordpress/favicon.ico' pattern='-d' => not-matched
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/favicon.ico -> favicon.ico
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)' to uri 'favicon.ico'
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/favicon.ico -> favicon.ico
...[rid#...a0/initial] (3) [perdir /...] applying pattern '^[_0-9a-zA-Z-]+/(.*\.php)$' to uri 'favicon.ico'
...[rid#...a0/initial] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/favicon.ico -> favicon.ico
...[rid#...a0/initial] (3) [perdir /...] applying pattern '.' to uri 'favicon.ico'
...[rid#...a0/initial] (2) [perdir /...] rewrite 'favicon.ico' -> 'index.php'
...[rid#...a0/initial] (3) [perdir /...] add per-dir prefix: index.php -> /var/www/wordpress/index.php
...[rid#...a0/initial] (2) [perdir /...] trying to replace prefix /var/www/wordpress/ with /
...[rid#...a0/initial] (5) strip matching prefix: /var/www/wordpress/index.php -> index.php
...[rid#...a0/initial] (4) add subst prefix: index.php -> /index.php
...[rid#...a0/initial] (1) [perdir /...] internal redirect with /index.php [INTERNAL REDIRECT]
...[rid#...28/initial/redir#1] (3) [perdir /...] strip per-dir prefix: /var/www/wordpress/index.php -> index.php
...[rid#...28/initial/redir#1] (3) [perdir /...] applying pattern '^index\.php$' to uri 'index.php'
...[rid#...28/initial/redir#1] (1) [perdir /...] pass through /var/www/wordpress/index.php
如果有人能够弄清楚为什么会发生这种情况,是什么让它发生,以及如何阻止它发生,我将不胜感激。
我认为 编辑 .htaccess
是WordPress的标准:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]