I would like to know if it is possible to format a URL like https://site1.com/en/article-details.test-article?item=test
to https://site1.com/en/article-details/test-article?item=test
so basically changing the .test-article
to /test-article
.
Because of how my site works it only recognizes .test-article
as a valid selector so reading up https://httpd.apache.org/docs/2.4/rewrite/flags.html it seems I may need to use a PT
flag to show the user the desired URL but pass the correct one to my site.
So far I have this to replace the dot for a slash
RewriteCond %{REQUEST_URI} ^/([a-z]{2})/article-details.([a-z]{2})(/?)$
RewriteRule ^/([a-z]{2})/.* https://%{SERVER_NAME}/$1/$2 [L,NC,R=301]
Edit(this works to format the URL as per RavinderSingh13’s suggestion)
RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/([a-z]{2})/article-details.([^?]*)(/?)$
RewriteRule ^ https://%{SERVER_NAME}/%1/article-details/%2 [QSA,R=301,NE,L]
2
Answers
With your shown samples, could you please try following. Please make sure you clear your browser cache before testing your URLs.
As per OP’s comments adding more Generic rules here:
You may try this rule as your topmost rule:
Change
302
to301
after testing this rule.