Answer the question
In order to leave comments, you need to log in
Remove the slash / at the end of the URL
Good afternoon. Help deal with the problem.
Apache 2.2.21
There is a URL like this: domain.tld/script < - exactly like that, without a slash at the end
And there is a directory /var/www/domain.tld/script/
When you try to access this URL, it redirects to domain.tld/ script /
(note the slash at the end).
Googling a little, I found out that mod_dir is doing this disgrace . And that there is a DirectorySlash off
directive that disables this behavior.
But here's something that doesn't work. I tried to put it in both VirtualHost and .htaccess - it still continues to redirect.
In an attempt to get rid of this effect, I tried to invent a similar rewrite:
But it does not give any effect. Rather, it causes a looping rewrite.
I suspect that I came across some kind of Apache bug, or specifically the mod_dir module.
And yet ... what to do?
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)/$ domain.tld/$1 [L]
Answer the question
In order to leave comments, you need to log in
I remember a friend had this problem, he asked me to fix it.
I poked and poked, but nothing worked. Then I opened this site instead of FF in Chrome - and there everything works as it should. I did "forget the site" in Firefox - it worked. FF often caches some unnecessary garbage and stubbornly displays it, despite CTRL + F5.
won't that help?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ /$1/ [R=301,L]
<Location /script>
DirectorySlash Off
SetHandler script-handler
Have you tried it with SetHandler?
Tell me, why do you think this is a problem and needs to be fixed?
Resurrect the topic!
point212 , did you manage to solve the problem?
Suddenly someone will fit.
For my needs, it turned out as follows:
DirectorySlash Off
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.*)/$ $1 [L,R= 301]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ $1/index.php [L]
This is for directories that didn't want to listen in any way.
For simple urls, you can add one more line:
RewriteRule ^(.*)/$ $1 [L,R=301]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question