M
M
Mega Sinyak2020-08-27 17:00:04
htaccess
Mega Sinyak, 2020-08-27 17:00:04

How to bring the plug to mind?

There is a plug:
/.htaccess

RewriteEngine on

RewriteCond %{HTTPS}_%{HTTP_HOST} ^(?|off_(?:www\.)?(.*)|on_www\.(.*)) [NC]
RewriteRule .* https://%1/$0 [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{DOCUMENT_ROOT}/public/$0 !-f
RewriteCond %{DOCUMENT_ROOT}/public/$0 !-d
RewriteRule .* /public/index.php?$0 [L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule .* /public/$0 [L]

Its essence is to remove the possibility of duplicating addresses like this:
1. site/controller
2. site/public/controller
That is, in the second case with public, we do not have access to the controller, since public becomes the controller :)

What does not suit you?

When entering the address site/publiс/, everything is fine, when you enter, site/publicas we see WITHOUT a slash, the address is appended and takes the following form site/public/?public.

I don’t use explicit GET parameters, so I think I’ll cut off QUERY_STRING, rewrote this line RewriteRule .* /public/index.php?$0 [L]to RewriteRule .* /public/index.php [L], the trouble with has ?publicdisappeared, but now when you enter without a slash or with a slash, we always have site/publiс/, that is, the last slash always appears.

How to remove the appearance of a slash at the end IF I ENTERED THE ADDRESS WITHOUT THE LAST SLASH?

ps the last slash always appears, ONLY AT ADDRESS /site/public, it does not apply to other addresses.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mega Sinyak, 2020-08-28
@mega-sinyak

DirectorySlash off

RewriteEngine on

RewriteCond %{HTTPS}_%{HTTP_HOST} ^(?|off_(?:www\.)?(.*)|on_www\.(.*)) [NC]
RewriteRule .* https://%1/$0 [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{DOCUMENT_ROOT}/public/$0 !-f
RewriteCond %{DOCUMENT_ROOT}/public/$0 !-d
RewriteRule .* /public/index.php [L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule .* /public/$0 [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question