Rewrite module for processing site version folders (strip slash)

I use the following rule to use folders for different versions:

RewriteEngine On
RewriteRule .* - [E=VERSION:020]
RewriteRule ^versions/(.*)$ versions/$1 [L]
RewriteRule ^(.*)$ versions/%{ENV:VERSION}/$1 [L]

I have a structure like:

http://domain.com/versions/020/
http://domain.com/versions/020/th?=1
http://domain.com/versions/020/myfolder/
http://domain.com/versions/020/myfile.html

But the user can see:

http://domain.com/
http://domain.com/th?=1
http://domain.com/myfolder/
http://domain.com/myfile.html

I have the last issue with a slash that shows the version number.

Second entry point (still working):

http://domain.com/site/

But the problem is when the user enters the URL and omits the end of the slash, for example:

http://domain.com/site

Now the user sees the version number as follows:

http://domain.com/versions/020/site/

This is a problem because I do not want the user to know about other versions.

Any idea how I can solve the problem?

+5
1

, mod_dir, , , . , , /site /versions/020/site, mod_dir http://domain.com/versions/020/site/. , /020 .

mod_dir "DirectorySlash Off" . - , , - .

RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R,L]

- , /version/020, , .

: , , , /, , DirectorySlash, mod_dir. , , ?

+1

All Articles