我正在尝试使用重写API添加新的重写规则:
add_rewrite_rule(\'product/([A-Z0-9]{10})\', \'index.php/product/?asin=$1\', \'bottom\');
add_rewrite_rule(\'product/(([A-Za-z0-9_])*)\', \'index.php/product/?product=$1\', \'bottom\');
add_rewrite_rule(\'compare/((([A-Z0-9]{10}),?)*)\', \'index.php/compare/?asin=$1\', \'bottom\');
add_rewrite_rule(\'categories/(([A-Za-z0-9]|\\-|\\_)*)\', \'index.php/categories/?subcategory=$1\', \'bottom\');
更新永久链接后,它会将以下行添加到
.htaccess
文件:
RewriteRule ^product/([A-Z0-9]{10}) /index.php/product/?asin=$1 [QSA,L]
RewriteRule ^product/(([A-Za-z0-9_])*) /index.php/product/?product=$1 [QSA,L]
RewriteRule ^compare/((([A-Z0-9]{10}),?)*) /index.php/compare/?asin=$1 [QSA,L]
RewriteRule ^categories/(([A-Za-z0-9]|\\-|\\_)*) /index.php/categories/?subcategory=$1 [QSA,L]
导致以下情况
.htaccess
文件:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteRule ^product/([A-Z0-9]{10}) /index.php/product/?asin=$1 [QSA,L]
RewriteRule ^product/(([A-Za-z0-9_])*) /index.php/product/?product=$1 [QSA,L]
RewriteRule ^compare/((([A-Z0-9]{10}),?)*) /index.php/compare/?asin=$1 [QSA,L]
RewriteRule ^categories/(([A-Za-z0-9]|\\-|\\_)*) /index.php/categories/?subcategory=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
但当我尝试访问以下URL时:
http://example.com/product/ABCDE324AB
这似乎不起作用。我总是得到一个找不到的页面。有什么想法吗?