Properly remove file extensions in URL in lighttpd - regex

Could you advise me how to remove file extensions properly in lighttpd?
So that:
Root directory ("/") is not going to be rewritten to "/.php"
Open directory if trailing slash is missing
All files can be accessed without extension
Another StackOverflow thread here have answers that do not fix (1):
Rewriting with lighttpd - how to remove file extensions

2) and 3) are mutually exclusive - how do you expect the system to know if blahBlah is meant to be a directory blahBlah or a file blahBlah.php?
1) is probably handled by DirectoryIndex, not by your rewrite rules

Related

How do I make a prettierrc file that completely disables prettier?

I'm editing a repository that doesn't use Prettier, but my editor (Emacs) loads prettier-js-mode based on file extension. So when saving a file I get a bunch of whitespace changes that I can't commit as it would polute the upstream repository.
My idea so far is to add a local .prettierrc file that disables Prettier, then add it to my .git/config/exclude file so upstream doesn't have to know about it.
But how do I craft such a file?
In my case I'd like to have a file in the project's root directory that would disable Prettier for the whole project, but I can also see how others might wish for a way to do the same thing for a subdirectory.
What about adding the .prettierignore with a * in it?
prettier-js-mode should have a config to only enable itself when it finds prettier config in the root or in package.json. The same as vscode and atom plugins do. If it doesn't have this feature it would be nice to open an issue or a PR.
The accepted answer is kinda hacky, but sure it will work too.

i download opencart new modules but put into file front end?

i use the version 3.0.0.1 version. i try lot but and admin > extension > installer > warring error alert The directory catalog/controller/common is not allowed to be written to!
When you are installing an extension from admin > extensions > installer then the OpenCart system is checking the write permission of allowed directory/folder listed on the file located in admin\controller\marketplace\install.php on near about line No. 124.
You need to add your missing path there. Copy the missing path and paste into the $allowed array and do not forget to add a trailing slash (/) at the end of your path. See an example of missing path catalog/controller/common below:
Here I'm adding the path with a trailing slash (/)
Everytime an error path you get you need to add on that file.

How to use the exclude_files regex in cpplint?

I am using cpplint to check my sourcode agains the google style guide.
Cpplint's help says:
cpplint.py supports per-directory configurations specified in CPPLINT.cfg
files. CPPLINT.cfg file can contain a number of key=value pairs.
Currently the following options are supported:
"exclude_files" allows to specify a regular expression to be matched against
a file name. If the expression matches, the file is skipped and not run
through liner.
Example file:
filter=-build/include_order,+build/include_alpha
exclude_files=.*\.cc
The above example disables build/include_order warning and enables
build/include_alpha as well as excludes all .cc from being
processed by linter, in the current directory (where the .cfg
file is located) and all sub-directories.
How I use cpplint:
I use cpplint by this command to check all files in my source folder:
cpplint src/*.c
Well there is one special file foo.cc which must not be checked. So I tried to create a CPPLIN.cfg to use the exclude_files property. My file looks like this:
set noparent
filter=-build/include_dir
exclude_files=foo.cc
Nevertheless foo.cc is still checked.
What I have already tried to do:
I tried exclude_files=/.*\.cc/. This should exclude all files ending with *.cc. Nevertheless all files are still checked.
I tried to remove my filter from the file. This caused more errors than before. So I am now sure that my CPPLINT.cfg file is found by cpplint.
Question:
How to use the exclude_files regex in cpplint correctly?
Turns out apparently that the doc is wrong: exclude_files only excludes files in the same directory as CPPLINT.cfg, not in subdirectories. See https://github.com/google/styleguide/issues/220
So the solution would be to create src/CPPLINT.cfg and put exclude_files=.*\.cc in it.

How do I create an exception for mod security?

When I checked the logs, I found Mod_security blocking some files necessary
for the site operation. So far, I disabled it per domain in the apache configuration file.
I want to only disable certain rules on certain pages.The implementation examples I read are specific to red hat and other distros.
I run Centos 5 with apache 2.8 and mod_security 2 (the server hosts multiple sites)
On centos, the loaded mod_security is included on top like this:
Include "/usr/local/apache/conf/modsec2.conf"
The above file calls modsec2.user.conf that is found in the same directory.
Here's what I've done so far:
My server does not have a directory called modsecurity.d for me to create a file like this:
/etc/httpd/modsecurity.d/modsecurity_localrules.conf
So I created a file named:
whitelist.conf
in:
/usr/local/apache/conf/
then I added an include to it in:
/etc/httpd/conf/modsec2.conf/
the rules look like:
<LocationMatch "/wp-admin/post.php">
SecRuleRemoveById 950006
</LocationMatch>
But the rules are not working. I wonder if whitelist.conf was placed in the right place.
I then created 2 files:
modsecurity_crs_15_customrules.conf
modsecurity_crs_60_customrules.conf
and placed them in:
/home/cpeasyapache/src/modsecurity-apache_2.5.12/rules
The above path is where I found:
modsecurity_crs_10_config.conf
that contains main rules though I haven't seen it called by any other file.
Base rules are found in:
/home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/base_rules
It seems my mod_security is installed and configured with minimal functionality.am thinking to add this to httpd.conf:
<IfModule security2_module>
Include /home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/modsecurity_crs_10_config.conf
Include /home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/base_rules/*.conf
Include /home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/optional_rules/*.conf
Include /home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/modsecurity_crs_15_customrules.conf
Include /home/cpeasyapache/src/modsecurity-apache_2.5.12/rules/modsecurity_crs_60_customrules.conf
</IfModule>
How do you guys do it on your end?
Thank you in advance

.hgignore syntax for ignoring only files, not directories?

I have a problem which I can't seem to understand. I'm using TortoiseHg (version 0.7.5) on Windows but on Linux I have the same problem. Here it is:
My .hgignore file:
syntax: regexp
^[^\\/]+$
What I'm trying to achieve is to add to the ignore list the files which are in the root of the hg repository.
For example if I have like this:
.hg
+mydir1
+mydir2
-myfile1
-myfile2
-anotherfile1
-anotherfile2
.hgignore
I want myfile1(2) and anotherfile1(2) to be ignored (names are only for the purpose of this example - they don't have a simple rule that can be put in the hgignore file easily)
Is there something I'm missing because I'm pretty sure that regexp is good (I even tested it)? Ideas?
Is there a simpler way to achieve this? [to add to the ignore list files that are in the root of the mercurial repository]
I relayed this question in #mercurial on irc.freenode.net and the response was that you cannot distinguish between files and directories — the directory is matched without the slash that you're searching for in your regexp.
However, if you can assume that your directories will never contain a full-stop ., but your files will, then something like this seems to work:
^[^/]*\..*$
I tested it in a repository like this:
% hg status -ui
? a.txt
? bbb
? foo/x.txt
? foo/yyy
Adding the .hgignore file gives:
% hg status -ui
? bbb
? foo/x.txt
? foo/yyy
I .hgignore
I a.txt
which indicates that the a.txt file is correctly ignored in your root directory, but x.txt in the foo subdirectory is not. You can also see that a file named just bbb in the root directory is not ignored. But maybe you can add such files yourself to the .hgignore file.
If you happen to have a directory like bar.baz in your root directory, then this directory and all files within will be ignored. I hope this helps a bit.
Here is a dirty trick:
Create an empty file ".hidden" in your directory, than add to .hgignore:
^mydir/(?!\.hidden).+$
This will ignore all files in the directory except ".hidden".