djones Posted September 17, 2010 Share Posted September 17, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/213663-help-writing-to-file-after-specific-keyword-in-file/ Share on other sites More sharing options...
Adam Posted September 17, 2010 Share Posted September 17, 2010 Forgive for asking the obvious, but you can't you just manually add these? You may also run into problems with write permissions; it's not likely PHP will have access by default. Quote Link to comment https://forums.phpfreaks.com/topic/213663-help-writing-to-file-after-specific-keyword-in-file/#findComment-1112088 Share on other sites More sharing options...
djones Posted September 17, 2010 Author Share Posted September 17, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/213663-help-writing-to-file-after-specific-keyword-in-file/#findComment-1112090 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.