0

On my localhost I have enabled htaccess evaluation in apache2.conf and now I keep getting 500 (Internal Server Error).

I think I have some faulty .htaccess files that not being evaluated caused no issues before, but now are causing the error. I used find /var/www/ -name ".htaccess" -print to find the files, but they are too many.

For now, I would like to rename ALL .htaccess files to old.htaccess wherever they are. Using: rename .htaccess old.htaccess results in this error in terminal:
syntax error at (eval 1) line 1, near ".".

Wrapping the filenames like rename ".htaccess" "old.htaccess" produces the same error.

What is the correct command to use.

1 Answer 1

0

rename doesn't work that way; you need to specify a PCRE (Perl Compatible Regular Expression) pattern and replacement to work with it.

For this purpose, mv is enough; a fast way to rename all the .htaccess files in /var/www would be to use find itself:

find /var/www -type f -name '.htaccess' -execdir mv {} old.htaccess \;

Sample output on a test hierarchy:

user@debian ~/tmp % tree -a
.
├── 1
│   └── .htaccess
├── 2
│   └── .htaccess
└── 3
    └── .htaccess

3 directories, 3 files
user@debian ~/tmp % find . -type f -name '.htaccess' -execdir mv {} old.htaccess \;       
user@debian ~/tmp % tree -a
.
├── 1
│   └── old.htaccess
├── 2
│   └── old.htaccess
└── 3
    └── old.htaccess

3 directories, 3 files
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .