# Useful .htaccess Snippets (phanan/htaccess)

> Snippets for Apache .htaccess files covering redirects and rewrites, security, performance and other server settings.

- Source: https://github.com/phanan/htaccess (read at commit 72179f9 on 2026-11-30). The selection and order are its curators'.
- This index: https://weeklymatcha.com/lists/phanan/htaccess
- 8 entries in 8 sections. 13,206 stars. Last push 2026-03-06. Licence NOASSERTION.
- Facts are from GitHub as of 2026-11-30. No descriptions are copied from the list.

## Rewrite and Redirection

### Remove Trailing Slash

- [Source](https://stackoverflow.com/questions/21417263/htaccess-add-remove-trailing-slash-from-url#27264788) · https://weeklymatcha.com/item/18c6876c10

### Redirect a Single Page

- [Source](https://css-tricks.com/snippets/htaccess/301-redirects) · https://weeklymatcha.com/item/6baa66442a

### Redirect Using RedirectMatch

- [Source](https://askapache.com/htaccess/301-redirect-with-mod_rewrite-or-redirectmatch.html#301_Redirects_RedirectMatch) · https://weeklymatcha.com/item/3f121f07b9

### Alias “Clean” URLs

- [Source](https://abeautifulsite.net/access-pages-without-the-php-extension-using-htaccess) · https://weeklymatcha.com/item/b15b52af85

## Security

### Deny Access to Backup and Source Files

- [Source](https://github.com/h5bp/server-configs-apache) · Shell · 3,247 stars · pushed 2026-07-14 · MIT · https://weeklymatcha.com/gh/h5bp/server-configs-apache

## Performance

### Compress Text Files

- [Source](https://github.com/h5bp/server-configs-apache) · Shell · 3,247 stars · pushed 2026-07-14 · MIT · https://weeklymatcha.com/gh/h5bp/server-configs-apache

## Miscellaneous

### Allow Cross-Domain Fonts

- [Source](https://github.com/h5bp/server-configs-apache/issues/32) · https://weeklymatcha.com/item/70eca292b3

### Auto UTF-8 Encode

- [Source](https://github.com/h5bp/server-configs-apache) · Shell · 3,247 stars · pushed 2026-07-14 · MIT · https://weeklymatcha.com/gh/h5bp/server-configs-apache
