【发布时间】:2016-05-17 22:27:58
【问题描述】:
我知道.htaccess URL 重写有很多线程,但我的情况似乎有点不同,我尝试了很多但它不起作用。
我当前的网址:http://example.com/forest/trees/?type=perennial
我需要的是: http://example.com/forest/trees/perennial
我只需要从 URL 中删除 ?type=。
编辑:URL 可以在任意位置的字符串之间包含连字符-(当然,域名除外)。也可以是dense-forest 或non-perennial。
这是一个自定义代码和插件,所以不能修改它。我只需要美化网址。
任何帮助将不胜感激。
到目前为止我在.htaccess 中尝试过的内容:
RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD)\ /forest\/trees\/\?type=([^&]+)
RewriteRule ^ \/forest\/trees\/%2\/? [L,R=301]
和
RewriteRule ^\/forest\/trees\/([^/]*)? /forest/trees/?type=$1 [L]
我当前的 Wordpress .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]
</IfModule>
# END WordPress
提前致谢。 :) 干杯!
【问题讨论】:
标签: wordpress .htaccess mod-rewrite