0

How should I add o a trailing slash at the end of a URL in apache traffic server? I checked that in normal Apache using rewrite and regex with the following configuration, if the user does not add a slash at the end of the url, it can be entered in different directories without error. But in server traffic, unfortunately, the syntax has changed and I found the following configuration, but it didn't work. Is this a bug or can it be done by modifying config?

example task: example.co/text/fast redirect to example.co/test/fast/ EXAMPLE – REDIRECT ALL URLS THAT DOESN’T HAVE A TRAILING SLASH TO URLS WITH A TRAILING SLASH in apache

RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ domain.com/$1/ [L,R=301]

EXAMPLE – REDIRECT ALL URLS THAT DOESN’T HAVE A TRAILING SLASH TO URLS WITH A TRAILING SLASH in Traffic server (this regex can recognize slash)-(it didnt work)

cond %{CLIENT-URL:PATH} /^([^.]*[^/])$/ set-redirect 301 http://different_origin.example.com/%{CLIENT-URL:PATH}/

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • Does this answer your question? [add trailing slash from URL of apache traffic server](https://stackoverflow.com/questions/76986905/add-trailing-slash-from-url-of-apache-traffic-server) – f_puras Aug 28 '23 at 08:16

1 Answers1

0

enter code herecond %{SEND_RESPONSE_HDR_HOOK} enter code herecond %{CLIENT-URL:PATH} /^([^.]*[^/])$/ enter code hereset-redirect 301 %[CLIENT-URL}/