2012年9月13日 星期四

get file basename


Two ways for getting base name frome file path.

/* way 1by Rifur */
static const char * _get_file_baseName(const char *str, int len)
{
        for( ; str[len-1] != '/' && len > 0; --len );
        return &str[len];
}                                                                                                                                 

/* way 2 */
static const char * gnu_basename(const char *path)
{
        const char *base = strrchr(path, '/');
        return base ? base+1 : path;
}



htaccess don't work no apache2, CustomLog don't dork



今天寫網頁時,發生了兩個問題:
1. .htaccess 沒有正常工作
2. 自訂 CustomLog ,不會正常輸出 log 內容 ( 有產生 log 檔案,但檔案內容一直都是空的 )


第一個問題,原因是:Using apache2 on a Ubuntu, the .htaccess does not work !
reference : https://www.dokuwiki.org/security

解決方法如下:

In the /etc/apache2/sites-available you need to modify the file default (or the file default-ssl if you use https rather than http)

Default for AllowOverride in the <Directory /var/www/> is none, should be all


第二個問題的解決方法:
別在 apache.conf 寫 CustomLog 腳本,要寫在這個檔案
 /etc/apache2/sites-available/default 才會動