Wordpress URL - GET parameter must be removed

I know there are many streams for rewriting a URL .htaccess, but my case seems to be a little different, and I tried a lot, but it does not work.

My current url is: http://example.com/forest/trees/?type=perennial

What I need: http://example.com/forest/trees/perennial

I just need to remove ?type=from the url.

EDIT: The URL can contain hyphens -between lines at any point (except for the domain name). It can be dense-forestor non-perennialalso.

This is custom code and a plugin, so it cannot change it. I just need a decorated URL.

Any help would be greatly appreciated.


What I have tried so far in .htaccess:

RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD)\ /forest\/trees\/\?type=([^&]+)
RewriteRule ^ \/forest\/trees\/%2\/? [L,R=301]

and

RewriteRule ^\/forest\/trees\/([^/]*)?  /forest/trees/?type=$1 [L]

My current Wordpress.htaccess is:

# 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

Thanks in advance. :) Hooray!

+4
1

.htaccess:

# BEGIN WordPress
RewriteEngine On
RewriteBase /

RewriteRule ^forest/trees/([^/]+)$ /forest/trees/?type=$1

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

URL- http://example.com/forest/trees/perennial /forest/trees/?type=perennial, Wordpress Dispatcher /index.php.

+1

Source: https://habr.com/ru/post/1627759/


All Articles