I have some troubles understanding how to dynamically put together simple one language website. I would really appreciate if somebody could explain me in baby language what every part of the code below means:
RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(php|css|js|gif|png|jpe?g|pdf)$
RewriteRule (.*)$ templates/index.php [L]
Thank you in advance!
# Enable RewriteEngine to rewrite URL patterns
RewriteEngine On
# Every URI that not (! operator) ends with one of .php, .css, .js, .gif, .png, .jpg, .jpeg or .pdf
RewriteCond %{REQUEST_URI} !\.(php|css|js|gif|png|jpe?g|pdf)$
# Will be redirected to templates/index.php
RewriteRule (.*)$ templates/index.php [L]
# Sample
# /foo/bar.php -> /foo/bar.php
# /foo/bar.html -> templates/index.php
RewriteEngine On
Turns the rewrite engine on
RewriteCond %{REQUEST_URI} !\.(php|css|js|gif|png|jpe?g|pdf)$
Matches all requests which end not with .php, .css etc.
!
= negates the following expression ("matches not")\.
= A single point (has to be escaped so it's taken literally. Without the backslash it would match every character)(php|css|js|gif|png|jpe?g|pdf)
= One of these options. jpe?g
means the e
is optional, so it matches jpg
and jpeg
$
= the end of the request.RewriteRule (.*)$ templates/index.php [L]
Redirects all request not matching the regular expression to templates/index.php
. [L]
means it's the last rule, so not other rules from this .htaccess get applied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With