CodeIgniter Forums
mistake in default .htaccess file? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: mistake in default .htaccess file? (/showthread.php?tid=78177)



mistake in default .htaccess file? - sneakyimp - 12-09-2020

I'm looking at the default htaccess file distributed with CI4 and it looks to me like there's a mistake in the .htaccess rule:
Code:
    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to the front controller, index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]

If I'm not mistaken, that \s\S in square brackets should match whitespace characters. Shouldn't that last line be this?
Code:
RewriteRule ^(.*)$ index.php/$1 [L,NC,QSA][/code]

EDIT: I see from the apache docs and the perl docs that [\s\S]* should match zero or more white space and non-whitespace characters.

I was having problems with this RewriteRule because I was trying to put it in my apache conf file (for better performance than .htaccess) but I was getting Bad Request responses. I solved the problem by putting a / before the index.php like so:
Code:
RewriteRule ^([\s\S]*)$ /index.php/$1 [L,NC,QSA]

Seems to be working now. Hope this helps someone else.


RE: mistake in default .htaccess file? - InsiteFX - 12-09-2020

No they were put there because there was a problem with the forward / slash


RE: mistake in default .htaccess file? - sneakyimp - 12-10-2020

(12-09-2020, 09:48 PM)InsiteFX Wrote: No they were put there because there was a problem with the forward / slash
I don't understand what you mean by 'they' ? Can you clarify what you mean here?


RE: mistake in default .htaccess file? - InsiteFX - 12-10-2020

The CodeIgniter 4 Developers, if I remember eight they added that when I was having trouble with
the forward slash on my Windows 10 Pro x64 which fixed the problem.


RE: mistake in default .htaccess file? - sneakyimp - 12-10-2020

(12-10-2020, 02:29 PM)InsiteFX Wrote: The CodeIgniter 4 Developers, if I remember eight they added that when I was having trouble with
the forward slash on my Windows 10 Pro x64 which fixed the problem.

This doesn't clarify your prior statment where you said "they were put there." They in that context could not possibly be referring to the Codeigniter devs. Please explain what you meant.


RE: mistake in default .htaccess file? - InsiteFX - 12-10-2020

The CodeIgniter Developer's put them in there.


RE: mistake in default .htaccess file? - sneakyimp - 12-11-2020

(12-10-2020, 09:37 PM)InsiteFX Wrote: The CodeIgniter Developer's put them in there.
I have no idea what you are trying to say in your last 3 comments.


RE: mistake in default .htaccess file? - InsiteFX - 12-11-2020

What don't you understand the CodeIgniter Development Team added that ([\s\S]) to the .htaccess file.


RE: mistake in default .htaccess file? - paulbalandan - 12-12-2020

See the relevant PRs and issues:

https://github.com/codeigniter4/CodeIgniter4/pull/3262
https://github.com/codeigniter4/CodeIgniter4/issues/3245
https://github.com/codeigniter4/CodeIgniter4/issues/3089