.htaccess

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
moviehive
Registered User
Posts: 190
Joined: Mon Oct 20, 2014 2:08 am
Name: Aaron T

.htaccess

Post by moviehive »

I am working on a homepage type extension and just wondering if there is someway of making the extension place a directoryindex code in the .htaccess or does that have to be done manually by each person who will use the extension?
User avatar
John P
Registered User
Posts: 1237
Joined: Mon Jan 21, 2008 3:55 pm
Location: Netherlands
Name: John
Contact:

Re: .htaccess

Post by John P »

You can write to the .htaccess file if you want.
Image
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign
User avatar
moviehive
Registered User
Posts: 190
Joined: Mon Oct 20, 2014 2:08 am
Name: Aaron T

Re: .htaccess

Post by moviehive »

So there's no way that when people install the extension it would put the code in the .htaccess file itself? Does it have to be done manually?
User avatar
John P
Registered User
Posts: 1237
Joined: Mon Jan 21, 2008 3:55 pm
Location: Netherlands
Name: John
Contact:

Re: .htaccess

Post by John P »

I wrote a long time ago something like this to have rules in .htaccess for a picture gallery.

Code: Select all

            $file = $phpbb_root_path.'/.htaccess';
            $fp = fopen( $file , 'r' );
            $content = fread( $fp , filesize($file) );
            fclose( $fp ); 
            
            $new = "# gallery\n";
            $sql = 'SELECT cid, title from ' . GALLERY_CATEGORIES_TABLE . ' WHERE title <> ""'; 
            $result = $db->sql_query($sql);
            while($row = $db->sql_fetchrow($result))
            {
                $title = ereg_replace(' ', '_', $row['title']);
                $new .= "RewriteRule ^".$title."_foto([0-9_]*)-o([a-zA-Z_+]*)\.html$ /gallery.php?op=viewpic&cid=".$row['cid']."&start=$1&orderby=$2 \n";
                $new .= "RewriteRule ^".$title." /gallery.php?op=viewthumb&cid=".$row['cid']."\n";
            }
            $new .= "# /gallery";
            
            $new = ereg_replace ('(# gallery)(.*)(# /gallery)', $new, $content); 
            $new_file = $phpbb_root_path.'/.htaccess';
            $fp = fopen( $new_file , 'w' );     
            fwrite( $fp , $new );    
            fclose( $fp );
Rewrite it for 3.1 and put it in a function
Image
Webhosting, Custom MODs, Technical management, MOD installation and Webdesign
Post Reply

Return to “Extension Writers Discussion”