我正在努力使用mod_rewrite,似乎无法修复它。我正在尝试做以下事情:
你能给我一些指示或建议吗?
.htaccess
# basics
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project/project.nl/
</IfModule>
<IfModule mod_rewrite.c>
#
# ?s=term -> zoeken/term
# wordpress has permalink search for searching
#
RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC]
RewriteRule ^$ zoeken/%1/? [NC,R,L]
# Internal rewrite zoeken -> search
#
RewriteRule project/project.nl/zoeken/(.+)$ search/$1/? [NC,PT,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
答案 0 :(得分:0)
问题在于导致斜杠并且没有将index.php和L标志添加到结果中。 这是解决方案:
RewriteCond %{QUERY_STRING} \\?s=([^&]+) [NC]
RewriteRule ^$ search/%1? [NC,L,R]
# Rewrite localized search url -> search/term
#
RewriteRule ^zoeken/(.+)$ index.php/search/$1 [NC,L]