Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by John_A

  1. Nothing, everything is the same there are just slight differences in the way things are done sometimes, e.g. parsing xml as php the syntax is slightly different in .htaccess due to PHP setups differing slightly. 99.9% of the time everything is identical, but there are sometimes a few lines in a .htaccess file somewhere that just have to differ. I'm perfectly happy with the hosting I have, I pay for a managed service and it was actually myself who asked for Litespeed on the one in question, initially when it was touted as a faster, drop-in replacement for Apache but it's now evident that there are a few (rare cases) where things have to be done a little differently. I'm happy with the speed improvements that has brought, but at the same time don't want to mess with my dev server at this time as I have other sites live elsewhere that are not on Litespeed but use the same dev server. Anyway, it is what it is and I am where I am. I'm quite happy with my setup (dev and multiple live servers), I don't do anything over-complicated. It worked perfectly before this issue (for 10+ years) and hopefully using requinix's solution it will continue to do so - it's no great hardship going forward if I occasionally need to make a .htaccess.dev file if there's a difference between dev and production. All I asked for was a way to quickly clone the existing .htaccess files as per the OP
  2. OK, here's the background... I used to use an environment variable to enable me to differentiate between my dev and production server, using this in .htaccess: - <IfDefine DEV_SERVER> # dev server specific stuff here </IfDefine> <IfDefine !DEV_SERVER> # production server specific stuff here </IfDefine> The environment variable "DEV_SERVER" was only ever set on my dev server, and never on production, obviously. This approach worked a treat until my production server host installed Litespeed as a replacement for Apache. Litespeed doesn't like the above, and ignores everything. I tried having different versions of .htaccess files for dev and production, but that's messy and dangerous, I like to be able to interchange all files at any time between the two. My dev server runs Apache 2.4 and I have no plans to change this. I read that you can specify a different filename for .htaccess by putting this in httpd.conf: - AccessFileName .htaccess.dev But (I think) you can't set an order of preference here (like, say, DirectoryIndex), so I'm thinking the simplest solution so that I can have identical copies is have my dev server use .htaccess.dev instead of .htaccess - the production server will simply ignore any .htaccess.dev files. If there's no difference (there doesn't always need to be, it depends on the site and htaccess requirements) then the .htaccess (if there is one) can just be copied and renamed. The dev server will use .htaccess.dev and the live server will still use .htaccess. Problem is, I've manually done some already and so that's why if there is already a .htaccess.dev file then it should be left as is. ETA: I realise this is now no longer a PHP problem, even though my first thought was to do it with a PHP script, it seems that was probably the more complicated approach.
  3. Wow, if that works then that's excellent, thanks a lot! I'll backup all just in case!
  4. Around 200! It is just a 1 off though.
  5. I've got a dev server which, for reasons I won't go into, needs to have different .htaccess files for each site (and subfolders within them) within it. But not always. What I need to do is: - For the folder I put the PHP script in, and every folder under it (the whole tree under it): - If there's a .htaccess file an no .htaccess.dev file, copy .htaccess and name the copy .htaccess.dev (and look in subfolders) If there's a .htaccess file and also a .htaccess.dev file, do nothing (but keep looking for subfolders) If there's neither a .htaccess or .htaccess.dev file, do nothing (but keep looking for subfolders) I'd try to come up with something myself, but getting it wrong will be fairly catastrophic! I'm sure the conditional copy / rename bit is relatively straightforward, but it's the recursive searching of the whole file-system under the script's location that I'm not sure about... Any help greatly appreciated, as always! I have SSH access, if it's easier done that way maybe I'm approaching it wrong?
  6. Thank-you both! I went with option #2, as it seemed the most straightforward. Worked perfectly
  7. I have a file in the same location as my PHP file, say test.txt, and in multiple locations it has content like: - href="http://www.domain.com/entry.php/256/1/this-is-the-title" or href="http://www.domain.com/entry.php/123/2/another-title" which I need replaced within the file to: - href="{EntryNumber=256.link}" and href="{EntryNumber=123.link}" Only the first number is needed for the replacement, it will be between 1 and 999. Everything between the 5th / and the 2nd " can be safely ignored and removed. This is not the only content in the line, and sometimes there may be more than one occurrence per line. I've got this so far: - $buffer = ""; $fp = file($file); foreach($fp as $line){ $buffer .= preg_replace(***struggling with this bit***); } fclose($fp); echo $buffer; file_put_contents($file, $buffer); Am I along the right lines generally? And I have no idea what the preg_replace should be as my regex is a bit trial and error, more error in this case... As always, any help greatly appreciated! EDIT: If it matters, the largest file I need to edit is 39Kb, and includes 175 occurrences of the replacements.
  8. Thanks again. It's part of a URL building function...to replace any non-alphanumeric characters with spaces, which are in turn replaced with dashes or underscores in the next part...
  9. Thanks for your reply Jacques1. I did check the manual before posting, and it says to use preg_replace_callback() instead. But if, as you say, the modifier in my code does nothing anyway, is my suggestion (i.e. to simply remove it) not the best approach in this case?
  10. I have this snippet which is giving a deprecated warning re the "e" pattern modifier in PHP5.5: - $result = preg_replace("/\[^a-zA-Z0-9]/e"," ",$result);I'm not even sure what the "e" modifier does, as it's not my code...maybe something to do with removing duplicates? Anyway, what's the best way to replace this so that it doesn't give the warning in PHP5.5, and will work in PHP7.0.0? I've got a feeling this might work :- $result= preg_replace("/\[^a-zA-Z0-9]/"," ",$result);but feel I might have over-simplified it, and it maybe doesn't quite do the same thing? Any help much appreciated!
  • 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.