Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

making apache and django add a trailing slash

My /train directory is aliased to a script in httpd.conf by: WSGIScriptAlias /train /some-path/../django.wsgi

And it works well, except for one problem. If a user goes to /train (with no trailing slash) it will not redirect him to /train/, but will just give him the right page. This is a problem because this way the relative links on this page lead to the wrong place when no trailing slash was used to access it.

How can this be worked out?

Thanks.

like image 960
user302099 Avatar asked Dec 18 '22 01:12

user302099


1 Answers

I'm using something like this for redirecting /train to /train/, what I do is redirecting all the URL than doesn't end with / to /train/.

<Location "/train">
     Order deny,allow
     Allow from all
     RewriteEngine on
     RewriteRule  !^.*/$  /train/  [R]
</Location>

WSGIScriptAlias /train /some-path/../django.wsgi
like image 150
Ferran Avatar answered Jan 30 '23 04:01

Ferran