-3

I am attempting to create my first WordPress plugin, based on a .htaccess idea of mine. I don't know PHP too, too well, but I can change around code and stuff.

How can I add .htaccess rules to .htaccess using PHP for WordPress?

For example, how would I use PHP to generate the following .htaccess code?:

<FilesMatch "\.(js|css)$">
ExpiresDefault A604800
Header append Cache-Control "proxy-revalidate"
</FilesMatch>

Thank you in advance.

Adam
  • 1
  • 2

1 Answers1

0

.htaccess is simply a text file, so you can write/ read/ remove content from it using PHP functions responsible for this. Maybe fopen and fwrite can make you do this with extra coding and management of file permissions.

Second: rewriting rules in .htaccess are concerning server configuration, I dont think there are functions in PHP responsible for configuring server behaviour. I am still looking for this and will give a feedback here.

Edit:

Look at these:

Edit .htaccess with PHP Jason Brumwell answer

Is PHP allowed to modify .htaccess file in current folder?

http://forums.devshed.com/php-development-5/editing-htaccess-with-php-552406.html

Good luck

Community
  • 1
  • 1
Adib Aroui
  • 4,981
  • 5
  • 42
  • 94