R
R
Roman Morozov2018-01-16 20:42:55
CodeIgniter
Roman Morozov, 2018-01-16 20:42:55

RewriteEngine and Order deny,allow?

Greetings,
I have CodeIgniter, in which all requests, if there is no such file or directory, go to index.php. For example, you can open site.ru/register - it will be processed by index.php, which already has routing.

RewriteEngine On

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

I also connected CloudFlare and I need to block all connections except IP from here https://www.cloudflare.com/ips/
I got this htaccess
htaccess
Order deny,allow
Deny from all

Allow from 103.21.244.0/22
Allow from 103.22.200.0/22
Allow from 103.31.4.0/22
Allow from 104.16.0.0/12
Allow from 108.162.192.0/18
Allow from 131.0.72.0/22
Allow from 141.101.64.0/18
Allow from 162.158.0.0/15
Allow from 172.64.0.0/13
Allow from 173.245.48.0/20
Allow from 188.114.96.0/20
Allow from 190.93.240.0/20
Allow from 197.234.240.0/22
Allow from 198.41.128.0/17

Allow from 2400:cb00::/32
Allow from 2405:8100::/32
Allow from 2405:b500::/32
Allow from 2606:4700::/32
Allow from 2803:f800::/32
Allow from 2c0f:f248::/32
Allow from 2a06:98c0::/29

RewriteEngine On

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

But if requests go to an existing file, then everything works and we see code 200.
And if we try to access CodeIgniter, for example, to the same site.ru/register, we see 403.
If we make RewriteEngine Off, we see code 404, which is not register file. Yes, it's gone, but it's already gone 403.
If you open an existing file, for example, site.ru/assets/style.css - then in all cases 200
Also if you force index.php, for example, site.ru/index.php /register - that too in all cases 200.
How to combine RewriteEngine and Order deny, allow?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question