我面临困难,将关键字重定向到wordpress 4.4设置中的搜索页面。我正在努力实现的是重写/重定向
www.site.com/__search+keyword.html到www.site.com/__?s=search+keyword&submit=Search
我已经尝试了在谷歌找到的每一个解决方案,但没有一个适用于这个版本。
.htaccess文件:
<IfModule mod_rewrite.c>
RewriteBase /wordpress/
RewriteRule ([^/]+)\.html$ ./?s=$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>我可以使用:http://localhost/wordpress/search/keyword搜索wordpress,但是我无法更改搜索url。我需要的是,只要有关键字,然后是.html,就会在url中启动搜索。我怎么才能完成这件事?
发布于 2016-05-23 12:33:33
试着改变你的规则:
捕获所有RewriteRule . /wordpress/index.php [L]
会阻止它达到你的规则
RewriteBase /wordpress/
RewriteRule ([^/]+)\.html$ ./?s=$1 [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]移动您的规则高于标准WP规则应该允许您的工作,如预期。
https://stackoverflow.com/questions/37387937
复制相似问题