VIDEO
1.
확장자 떼기
현재: https://homzzang.com/test.php
목표: https://homzzang.com/test
수정: https://homzzang.com/.htaccess
https://homzzang.com/test
RewriteEngine On
RewriteRule ^test ?$ test.php
https://homzzang.com/dk
RewriteEngine On
RewriteRule ^dk ?$ test.php
https://homzzang.com/dk.xml
RewriteEngine On
RewriteRule ^dk.xml ?$ test.php
2.
쿼리단축 (1개)
현재: https://homzzang.com/user.php?id=1
목표: https://homzzang.com/user/1
수정: https://homzzang.com/.htacces
https://homzzang.com/user /1
RewriteEngine On
RewriteRule ^test?$ test.php
RewriteRule ^user /([0-9]+) user.php?id=$1
https://homzzang.com/us /1
RewriteEngine On
RewriteRule ^test?$ test.php
RewriteRule ^us /([0-9]+) user.php?id=$1
[파일소스]
https://homzzang.com/test.php
<?php
$i = 1;
while($i<=10){
echo "<a href='user.php?id=$i'>User ".$i."</a><br>";
$i++;
}
include 'style.css';
?>
cf. 참고
아래 소스 경우엔, user.php로 갔다가 다시 test.php로 바로 되돌아 옴.
echo "<a href='user/$i'>User ".$i."</a><br>";
[파일소스]
https://homzzang.com/user.php
<?php
if(!isset($_GET['id'])) {
header('location: test.php');
}
else if(isset($_GET['id'])) {
echo "User ID : ".$_GET['id']."<br>";
}
include 'style.css';
?>
3.
쿼리단축 (2개)
현재: https://homzzang.com/user.php?id=1&uid=2
목표: https://homzzang.com/user/1/2
수정: https://homzzang.com/.htacces
https://homzzang.com/user /1/2
RewriteEngine On
RewriteRule ^test?$ test.php
RewriteRule ^user /([ [0-9a-z A-Z ]+)/ ([0-9a-z A-Z ]+) user.php?id=$1&uid=$2
[파일소스]
https://homzzang.com/test.php
<?php
$i = 1;
while($i<=10){
$j = 99;
echo "<a href='user.php?id=$i&uid=$j'>User ".$i."</a><br>";
$i++;
}
include 'style.css';
?>
cf. 참고
아래 소스 경우엔, user.php로 갔다가 다시 test.php로 바로 되돌아 옴.
echo "<a href='user/$i/$j'>User ".$i."</a><br>";
[파일소스]
https://homzzang.com/user.php
<?php
if(!isset($_GET['id'])) {
header('location: test.php');
}
else if(isset($_GET['id']) && isset($_GET['uid'])) {
echo "User ID : ".$_GET['id']."<br>"; echo "My ID : ".$_GET['uid'];
}
include 'style.css';
?>
VIDEO
주소 복사
랜덤 이동
최신댓글