RewriteRule을 이용한 URL 매핑

/program/www/.htaccess

 

RewriteEngine On
 
RewriteBase /
 
RewriteCond $1 !^(optimizer\.php)
RewriteRule ^(.*)$ index.php?controller=$1&%{QUERY_STRING} [L]

적용전에 주의할 사항은 아파치 설정에 해당디렉토리의 htaccess 사용권한이 있는지 체크하셔야 합니다.

AccessFileName .htaccess
 
<Directory "/path/to/~">
    Options +FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

 

이미지 디렉토리 제외

RewriteEngine On
 
RewriteBase /
 
RewriteCond $1 !^(optimizer\.php|img)
RewriteRule ^(.*)$ index.php?controller=$1&%{QUERY_STRING} [L]

 

 

 

 

 

conf/rewrite.conf

RewriteEngine On
RewriteRule ^/img($|/.*) /home/resource/img/$1 [PT]
RewriteRule ^/optimizer\.php /home/12r/framework/direct/optimizer.php?%{QUERY_STRING} [L]
RewriteRule ^(.*)$ /home/12r/framework/index.php?controller=$1&%{QUERY_STRING} [L]

 

conf/alias.conf

Alias /img "/home/resource/img"
<Directory "/home/resource/img">
    Options MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

 

Virtual Host 설정

<VirtualHost *:80>
    DocumentRoot "/home/user1/www"
    ServerName foobar.cafe24test.com
    ServerAlias foobar.cafe24test.com
 
    Include conf/alias.conf
    Include conf/rewrite.conf
</VirtualHost>

 

posted @ 2014-09-30 16:41  appsolution  阅读(175)  评论(0)    收藏  举报