Reputation: 153
I'm trying to force a slash at the end of an url.
#i want this url https://example.com/it/parameter/
#with the slash
RewriteRule ^it/([a-z]+)/?$ it_page.php?p=$1 [L]
#and this rewrite too
#i want this url https://example.com/it/parameter/par1-mod-par2
#without slash at the end
RewriteRule ^it/([^/]+)/(.+)\-mod\-(.+)$ it_page.php?p=$1&q0=$2&r=$3 [L]
Because with this code when i enter : https://example.com/it/parameter it's not redirected to https://example.com/it/parameter/ so it creates a duplicate content.
Upvotes: 1
Views: 50
Reputation: 41219
You can use this :
RewriteEngine on
#Enforce a trailing slash on URIs with specific format `/it/perameter`
RewriteRule ^it/[^/]+$ %{REQUEST_URI}/ [L,R=301]
#RewriteRules
RewriteRule ^it/([a-z]+)/$ it_page.php?p=$1 [L]
RewriteRule ^it/([^/]+)/(.+)-mod-([^/]+)$ it_page.php?p=$1&q0=$2&r=$3 [L]
Upvotes: 2