2013-04-23 30 views
1

的代码行:的WordPress htaccess的并没有改变网址,只是去到404

RewriteRule ^/test/(.*)/?$ http://test.com/test/index.php?route=$1 [L,QSA] 

已在htaccess文件没有影响我使用:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
RewriteRule ^/test/(.*)/?$ http://test.com/test/index.php?route=$1 [L,QSA] 

</IfModule> 

# END WordPress 

当我访问我的域名。 com/test/123,Wordpress重定向到404页面而不是新链接。 我曾尝试移动htaccess文件中的项目,以防它们被覆盖,但不是运气。有任何想法吗?

回答

1
  • 问题1:RewriteRule与引导斜杠不匹配。

  • 问题2:重写规则的顺序错误。

这里是固定的版本:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/

RewriteRule ^test/(.*)/?$ http://test.com/test/index.php?route=$1 [L,QSA,NC] 

RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 
+0

谢谢你的作品。 – scott 2013-04-23 15:26:41

+0

不客气,很高兴它解决了。 – anubhava 2013-04-23 15:32:06

+0

你知道为什么当我改变: RewriteRule^test /(.*)/?$ http://test.com/test/index.php?route=$1 [L,QSA,NC] to RewriteRule^test /(.*)/?$ /test/index.php?route=$1 [L,QSA,NC]它不再起作用(基本上它与外部域一起工作,但是指的是我的服务器上的站点... – scott 2013-04-23 16:37:03