打印

[CPG] 精簡網址

[CPG] 精簡網址

基本上就是讓; T& B8 v) F  {  e: M0 c
; P2 }! y8 k5 S. x3 K7 J; s
http://pic.segaa.net/segaa+ h7 G2 T9 K/ Z

: I2 T) z* |/ a! e9 o. n/ p& ~自動相通於
: I2 a$ _3 C' ~9 a0 G  X  ]% W: ]3 a0 l
http://pic.segaa.net/index.php?cat=10002
# \4 b: O. o1 W+ ]* y) R! B% M" T$ f" ?5 E9 j) @: O: u) i4 l/ M$ R: a
讓使用者簡單的記住自己相簿的網址
" V$ X* E0 }0 b1 u- L' E' x" J  w# c1 K7 Y& a, ?% k6 L
編輯index.php 加入以下這些& ^& U' G2 D* z" P9 v
cpg134_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

進階的精簡網址 ... 基本上直接開啟外掛就好了 ! O/ o* p1 c9 n/ H8 l% E  m3 @
) p2 O# P# F+ a  ]% F, X/ y
4 I% N$ O2 D- n) K  N0 A. F6 w3 H, d
1. 登入管理者之後 -> 設定 -> 允許外掛  點 是 -> 確認
# _3 `6 x% Q! n6 T3 J* r* I0 c5 e! x" }+ `. P) {
2. 設定 -> ( 外掛管理 ) -> 名稱 Search Engine Friendly URLs v1.0 -> 旁邊有一個 i 的圖形點下去
( h  E3 V! y: u$ {/ E6 @3 W    選擇覆蓋掉原本的 .htaccess 檔 9 C3 q; A5 ^* m# m) c

2 u' ]2 H: p+ S! z" |5 R3. 但是這樣作會讓之前的 http://pic.segaa.net/segaa 失效 , 所以再把上篇的內容加回去
8 r  s2 r, X$ G0 Q) w, Q3 b# ?6 `+ T* C9 X: R
下面是我目前的 .htaccess 檔 . u$ u* @' n' G4 A
0 }2 L/ m0 h3 @& k9 A+ P
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 太少上論壇看東西了
" v. q: Y. C* A' l* _這邊原本是我用來丟些文件用的 . Z4 E) m8 n4 i' v% F
關於這個問題,可能你要直接進資料庫,看你資料庫中所使用的欄位名稱
. `7 [& j5 J% h) p# o& Y! p& g7 ]9 E& L1 [: B$ [- \
$ h  G1 m6 J- g. }" G
引用:
原帖由 prolog 於 2006-11-21 02:46 PM 發表
$ s2 {0 S. E4 v' I5 p其實關於精簡網址
. L- t2 @" w$ `這邊站長的教學寫的很清楚了# i  V$ X2 v# N$ X6 f
謝謝
( c# n+ ^& \# T; I7 T* K+ t9 @1 p! ]/ c5 I9 l) k; p
但是我照做之後: Y% {  U& p+ i+ f
不能連入相簿了
3 U8 F$ B; G3 g: v/ t他告訴我這行有誤
5 M4 N6 }% q: \0 U" A( k$sql = "SELECT user_id from `cpg134_users`  ...

TOP

發新話題