Unable to use htaccess multiple query strings properly
P粉312631645
P粉312631645 2024-03-31 17:05:58
0
1
473

I want to get this URL:

example.com/scooter-details/1/vespa-sprint

But the URL I get is:

example.com/scooter-details.php?scooter_id=1&scooter_brand=vespasprint&scooter_model=

scooter_model "sprint" is in the scooter_brand query, which usually must be scooter_brand=vespa&scooter_model=sprint. Hope you can help me solve this problem

This is htaccess code

Options +FollowSymLinks -MultiViews
RewriteEngine On
# SEO FRIENDLY URL

# Redirect "/scooter-details.php?service_id=<num>" to "/scooter-details/<num>"
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^scooter_id=(\d+)&scooter_brand=([^/.]+)&scooter_model=([^/.]+)$
RewriteRule ^(scooter-details)\.php$ //%1/%2-%3? [QSD,L,R=301,N]

# Rewrite "/scooter-details/<num>" back to "scooter-details.php?service_id=<num>"
RewriteRule ^(scooter-details)/(\d+)/([^/]+)$ .php?scooter_id=&scooter_brand=&scooter_model= [L]

P粉312631645
P粉312631645

reply all(1)
P粉320361201

If you want to capture elements of the query string (i.e. already URL encoded) and use them to build a URL path. Otherwise, you'll end up with the double URL-encoded portion of the resulting URL path - that's what it looks like.

%20 is a double URL encoded space. ie. It appears that the query string you are capturing has (i.e. spaces) in it.

However, the rule you posted seems to have nothing to do with the example URL given?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template