Facebook 

SMFHacks.com - Celebrating 20 Years!

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4342
Latest: eva
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 44312
Total Topics: 7676
Most Online Today: 513
Most Online Ever: 27044
(May 30, 2026, 09:10:16 pm)
Users Online
Members: 0
Guests: 443
Total: 443

Author Topic: Version 4.3.1 Wipes .htaccess file on initial install  (Read 16652 times)

0 Members and 1 Guest are viewing this topic.

Version 4.3.1 Wipes .htaccess file on initial install
« on: »
Works very well. The only issue I have with it is that when you install it, PrettyURLs will wipe your .htaccess file clean. This is not good for users who have entries already in the .htaccess file. However updating PrettyUrls after installation will leave the .htaccess entries intact. Using SMF 2.1.7.

There seems to be an issue here in the Subs-PrettyUrls.php file:

Code: [Select]
// Backup the old .htaccess file
 @copy($boarddir . '/.htaccess', $boarddir . '/.htaccess.backup');

 // Replace the old with the new, if we can
 $oldHtaccess = file_get_contents($boarddir . '/.htaccess');
 $pattern = '~# PRETTYURLS MOD BEGINS.+# PRETTYURLS MOD ENDS~s';
 if (preg_match($pattern, $oldHtaccess, $match))
 $htaccess = str_replace($match[0], $htaccess, $oldHtaccess);

$htaccess starts out as PrettyUrls code and if there is no match in the $oldHtaccess file it just overwrites existing information in the .htaccess file with the PrettyUrls information wiping out all existing entries.

I believe what is needed is this to keep existing entries when no match of the $pattern is found:

Code: [Select]
if (preg_match($pattern, $oldHtaccess, $match))

    $htaccess = str_replace($match[0], $htaccess, $oldHtaccess);
 else
    $htaccess = $htaccess . PHP_EOL . $oldHtaccess;
« Last Edit: April 14, 2026, 06:38:44 am by Randem »

 

Related Topics

  Subject / Started by Replies Last post
19 Replies
15550 Views
Last post November 09, 2010, 03:28:42 pm
by xhoster1
0 Replies
9272 Views
Last post March 26, 2013, 03:18:47 am
by PyroTech03
0 Replies
2405 Views
Last post November 18, 2022, 05:43:04 pm
by CWVRV
1 Replies
3946 Views
Last post November 18, 2022, 06:55:45 pm
by SMFHacks
2 Replies
20008 Views
Last post May 11, 2026, 07:43:36 am
by VP Sandman

+- Recent Topics

Registration - anti bot pattern matching by SMFHacks
November 01, 2026, 07:20:17 pm

EZPortal 8 by davejo
October 21, 2026, 01:01:54 pm

Downloads Pro 7.0 Released by SMFHacks
October 07, 2026, 07:35:30 pm

[Mod]ActivityPub Federation for SMF 2.1 by SMFHacks
October 01, 2026, 05:03:45 pm

Newsletter Pro 4.0 Released by SMFHacks
September 23, 2026, 08:08:24 pm

Can't remove or restore any item from the recycle bin by SMFHacks
September 22, 2026, 11:01:51 am

MCP Server for SMF 2.1 - let Claude, ChatGPT or Cursor run your admin chores by SMFHacks
September 12, 2026, 02:50:45 pm

Suggestions for improvements to Ultimate Shoutbox & Chatroom by davejo
September 02, 2026, 01:35:09 am

Automatic Sorting of Categories by Kiwi
August 31, 2026, 12:36:09 am

' appears as ' in Most Viewed (and Recent Items ?) by SMFHacks
August 22, 2026, 11:01:56 pm

Powered by EzPortal