.htaccess code, is this example good coding practice? -


now feet officially wet .htaccess have new question. in 1 of many tutorials have bookmarked, author recommends placing bit of code @ beginning of .htaccess file:

adddefaultcharset utf-8 rewriteengine on rewritebase / 

i can understand issues of avoiding parsing issues first line, want know is, aside rewriteengine on other 2 lines practice or adding bloat?

many thanks!

the rewritebase / line used resolve relative uris in target and/or patterns of rewriterule's. example, if htaccess file in /foo directory, , have rules might this:

rewriteengine on rewritebase /foo/ rewriterule ^bar$ index.php?bar [l] 

here, rule's target index.php?bar relative uri , base gets prepended it, resulting in uri: /foo/index.php?bar. when rule's target relative, apache make guess whether uri file-path or url-path, , doesn't guess correctly. rewritebase /foo/, apache knows /foo/index.php url-path. there instances rewrite base doesn't match folder it's in, result still same. acts uri base relative uri's in rules.

having doesn't hurt, unless reason want relative uri's map file-paths.

the adddefaultcharset directive doesn't apply character set of htaccess file, it's part of response webserver gives requests when requested content of type text/html or text/plain. again, doesn't hurt have in htaccess file unless you're text or html content other encoding (like *shift_jis* example).


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -