Jump to content

Help writing to file after specific keyword in file


djones

Recommended Posts

I need to add these lines to my .htaccess file via PHP

 

RewriteCond %{REQUEST_URI} checkout 
RewriteRule ^(.*)$ https://myurl.com/checkout/$1 [R,L]

 

RIGHT after this line:

RewriteBase /

 

AND before this line:

RewriteCond %{REQUEST_FILENAME} !-f

 

This is how the current file looks w/o the new line addition:

 

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php [L,QSA]

 

It needs to look like this when the new lines are added(extra line breaks not necessary):

 

RewriteBase /

RewriteCond %{REQUEST_URI} checkout 
RewriteRule ^(.*)$ https://myurl.com/checkout/$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php [L,QSA]

 

The line numbers may not match up, so I cannot use the line number.

I'm allowing the user to turn on SSL for the checkout page. I am checking if the file is writable via PHP, if it is I want PHP to add these lines, if it's not I am telling the user they need to add these lines manually.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.