2010년 11월 19일 금요일

[LINUX]mod_rewrite 예제

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/([a-z0-9_-]+)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /test/index.php [L]

이것은

http://domain.com/test

라는 아이디를
/test/test.php로 보내라는 의미 입니다.

받는 페이지에서는 즉 test.php

<?php
$a = $_SERVER['REQUEST_URI'];

하면 뒤에 따라 오는 test 라는 문자열을 찾을 수 있습니다.

이것을  사용하기 위해서는

http.conf

<VirtualHost>
  AllowOverride All
  Options FollowSymLinks

</VirtualHost>

위 설정이 추가 되어야 합니다.

0 개의 댓글:

댓글 쓰기