打印

[CPG] 精簡網址

[CPG] 精簡網址

基本上就是讓
/ B) K9 i: S* n+ v% D4 q! Q0 p5 g6 D6 W, ~2 Q: [
http://pic.segaa.net/segaa
: A2 [5 b5 I, l: T5 k  I% _1 s! e
, n0 R: s1 H) N% u# g7 y/ p自動相通於
3 E6 v2 U! Y0 d" D5 S+ D' B% F$ o+ [! F6 v/ c& a, ~! N/ e( x
http://pic.segaa.net/index.php?cat=10002
0 Y. U& a2 ?1 O6 @- K! [
4 @, t+ ]+ H7 [) s1 p( ~. Q讓使用者簡單的記住自己相簿的網址
1 |) Y& x' I6 L, y" H6 B- V
9 `+ o" `. I) D0 p1 D5 V編輯index.php 加入以下這些
% `. v  b* Z) M. F$ Tcpg134_user <- 這邊請自行修改
複製內容到剪貼板
代碼:
$qq=$HTTP_SERVER_VARS["QUERY_STRING"];
if (!strstr($qq,'=') and !empty($qq)) {
$qq = eregi_replace ( '%20', ' ', $qq);
$qq=mysql_escape_string($qq);
$sql = "SELECT user_id from `cpg134_users` WHERE `user_name` = "$qq"";
$result1 = mysql_query($sql);
if (mysql_num_rows($result1)>0) {
list($uid) = mysql_fetch_array($result1);
$cat = sprintf("1%04d",$uid);
}
mysql_free_result($result1);
}





//
// Main code
//
編輯 .htacess
複製內容到剪貼板
代碼:
<Files .htaccess>
deny from all
</Files>

RewriteEngine On
RewriteBase /
RewriteRule ^([A-Za-z_0-9-]+)/*$ /?$1 [L]
RewriteRule ^user-([0-9a-zA-Z]+)$ /index.php?cat=$1
RewriteRule ^user/([0-9a-zA-Z]+)$ /index.php?cat=$1
RewriteRule ^user/$ /index.php
RewriteRule ^my$ /profile.php?op=edit_profile
RewriteRule ^new$ /thumb.php?album=lastup
RewriteRule ^hot$ /thumb.php?album=topn


<Files user>
ForceType application/x-httpd-php
</Files>

#ErrorDocument 401 /index.php
#ErrorDocument 403 /index.php
#ErrorDocument 404 /index.php

TOP

進階的精簡網址 ... 基本上直接開啟外掛就好了 - d! r& _. \8 @6 c0 ]

' N& W8 q& W. y* o- S
3 z) H, _* {" V$ X1 A- _4 m1. 登入管理者之後 -> 設定 -> 允許外掛  點 是 -> 確認 ) ]6 f7 E3 e- s0 w. k. z+ @

: s5 q) X5 e/ F, J: B* |2. 設定 -> ( 外掛管理 ) -> 名稱 Search Engine Friendly URLs v1.0 -> 旁邊有一個 i 的圖形點下去
$ _$ c! Q4 \' C- N8 b# M    選擇覆蓋掉原本的 .htaccess 檔 7 q* h7 Z! ?0 p0 P7 D' G
% L+ c8 c1 S. L
3. 但是這樣作會讓之前的 http://pic.segaa.net/segaa 失效 , 所以再把上篇的內容加回去2 T7 T  F  J$ K+ E. G3 V* c7 C& A. A
' x' E7 \( K& f% T( U4 q
下面是我目前的 .htaccess 檔   T7 x" u( {3 h. S
7 ?$ [, i9 n( g( f3 S6 c
ps.我將 displayimage.php 改成 display.php thumbnails.php 改成  thumb.php
複製內容到剪貼板
代碼:
<Files .htaccess>
deny from all
</Files>


Options FollowSymLinks SymLinksIfOwnerMatch

RewriteEngine on

RewriteEngine On
RewriteBase /
RewriteRule ^([A-Za-z_0-9-]+)/*$ /?$1 [L]
RewriteRule ^user-([0-9a-zA-Z]+)$ /index.php?cat=$1
RewriteRule ^user/([0-9a-zA-Z]+)$ /index.php?cat=$1
RewriteRule ^user/$ /index.php

#  Uncomment the following line if your webserver's
#  URL is not directly related to physical file paths.
#  Update "YOUR_COPPERMINE_ROOT" (just / for root)

#RewriteBase /YOUR_COPPERMINE_ROOT

#
# Rewrite index urls
#
RewriteRule index-([0-9]*)\.html index.php?cat=$1 [NC]

RewriteRule index-([0-9]*)-page-([0-9]*)\.html index.php?cat=$1&page=$2 [NC]

#
# Rewrite thumbnail urls
#
RewriteRule thumbnails-([a-z0-9]*)-([\-]?[0-9]*)\.html thumbnails.php?album=$1&cat=$2 [NC]

RewriteRule thumbnails-([a-z0-9]*)-page-([0-9]*)\.html thumbnails.php?album=$1&page=$2 [NC]

RewriteRule thumbnails-([a-z0-9]*)-([\-]?[0-9]*)-page-([0-9]*)\.html thumbnails.php?album=$1&cat=$2&page=$3 [NC]

RewriteRule thumbnails-([0-9]*)\.html thumbnails.php?album=$1 [NC]
RewriteRule thumb-search-(.*)\.html thumb.php?album=search&search=$1 [NC]

#
# Rewrite displayimage urls
#
RewriteRule displayimage-([a-z0-9]+)-([\-]?[0-9]+)-([\-]?[0-9]+)\.html displayimage.php?album=$1&cat=$2&pos=$3 [NC]

RewriteRule displayimage-([a-z0-9]+)-([\-]?[0-9]+)\.html displayimage.php?album=$1&pos=$2 [NC]

RewriteRule displayimage-([0-9]+)\.html displayimage.php?pos=-$1 [NC]

RewriteRule slideshow-([0-9]+)-([\-]?[0-9]+)-([0-9]+)\.html displayimage.php?album=$1&pid=$2&slideshow=$3 [NC]

RewriteRule slideshow-([a-z]+)-([\-]?[0-9]+)-([0-9]+)-([0-9]+)\.html displayimage.php?album=$1&cat=$2&pid=$3&slideshow
=$4 [NC]

RewriteRule display-([a-z0-9]+)-([\-]?[0-9]+)-([\-]?[0-9]+)\.html display.php?album=$1&cat=$2&pos=$3 [NC]

RewriteRule display-([a-z0-9]+)-([\-]?[0-9]+)\.html display.php?album=$1&pos=$2 [NC]

RewriteRule display-([0-9]+)\.html display.php?pos=-$1 [NC]

RewriteRule slideshow-([0-9]+)-([\-]?[0-9]+)-([0-9]+)\.html display.php?album=$1&pid=$2&slideshow=$3 [NC]

RewriteRule slideshow-([a-z]+)-([\-]?[0-9]+)-([0-9]+)-([0-9]+)\.html display.php?album=$1&cat=$2&pid=$3&slideshow=$4 [
NC]

<Files user>
  ForceType application/x-httpd-php
  </Files>

  #ErrorDocument 401 /index.php
  #ErrorDocument 403 /index.php
  #ErrorDocument 404 /index.php

TOP

sorry 太少上論壇看東西了 + D5 m  m9 _! o$ I  t0 T
這邊原本是我用來丟些文件用的   [: l( k  V# h8 t0 _4 L
關於這個問題,可能你要直接進資料庫,看你資料庫中所使用的欄位名稱1 V$ b9 i# X( B. @8 w& E% G
# n! X7 y: t8 t) Y4 Q

. n4 f$ ^0 Y# B5 }2 N/ p
引用:
原帖由 prolog 於 2006-11-21 02:46 PM 發表7 Y, E- u5 f1 W3 r, n0 ]& _3 b
其實關於精簡網址
6 D) a, v8 U1 d8 h這邊站長的教學寫的很清楚了
+ M1 r6 M5 G/ _謝謝( b! B6 `2 F( N. m8 \1 ^
0 Z* l, t; _5 q* k0 q
但是我照做之後
; ?0 s4 v" F% y: C6 U不能連入相簿了$ B; f1 G: t: u. K6 b
他告訴我這行有誤
& |# q* _$ B5 x$sql = "SELECT user_id from `cpg134_users`  ...

TOP

發新話題