打印

[CPG] 精簡網址

[CPG] 精簡網址

基本上就是讓, q* D, p% N' a: e6 ~6 A, S

: g7 }# y# k8 Q& |4 t4 phttp://pic.segaa.net/segaa; X5 O! J9 J6 E+ s

; N3 d- l" T8 R% M3 t自動相通於
! i9 @0 Q( c# i. g) U3 ~8 ]2 ~* B5 m, U# o; ^0 N
http://pic.segaa.net/index.php?cat=10002
' ?# @( ^5 r; }, q* m5 f. z3 l$ Z. y: h& e' j8 I! ?
讓使用者簡單的記住自己相簿的網址
% a' a9 x+ Z) f$ c
* b3 M% L* T7 W' r5 A0 j編輯index.php 加入以下這些$ l9 U0 h) B0 C4 {8 ^$ F+ ]
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

進階的精簡網址 ... 基本上直接開啟外掛就好了
0 j' H# C4 w2 P9 r8 y0 U6 [( Z& U; V- ~6 Q' T- n

/ S( R% ?: L8 o: x; @0 W1. 登入管理者之後 -> 設定 -> 允許外掛  點 是 -> 確認
: v, r  _) N6 S1 h
; u$ u8 f7 H8 F$ `0 z2. 設定 -> ( 外掛管理 ) -> 名稱 Search Engine Friendly URLs v1.0 -> 旁邊有一個 i 的圖形點下去
! X8 e/ y/ h9 @) K    選擇覆蓋掉原本的 .htaccess 檔 6 t7 g; t2 O' K4 F& n$ F: q
# X7 Y; e: X3 k* }0 G- W
3. 但是這樣作會讓之前的 http://pic.segaa.net/segaa 失效 , 所以再把上篇的內容加回去+ X8 U, M1 Q* O6 ]- M3 j* y' ^

( H* q: ?! Q2 T- r2 Q% n下面是我目前的 .htaccess 檔 8 s, P& D  d; D4 D* N; S8 M$ d

  M4 ^" s2 C: H- x7 zps.我將 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 太少上論壇看東西了
' w. H3 Q8 y) T) _3 e$ Q+ ]這邊原本是我用來丟些文件用的 # c4 Q. n( n  t0 W! J
關於這個問題,可能你要直接進資料庫,看你資料庫中所使用的欄位名稱
9 M$ J5 c1 C" K$ X0 v. N( }8 V7 ^1 d& t2 l" ~7 d5 W1 J$ @

+ r" W% Q# O& _4 ~& `
引用:
原帖由 prolog 於 2006-11-21 02:46 PM 發表8 A0 K. C& ^+ e; e  _2 _
其實關於精簡網址# P0 N" W4 A7 K- H8 J
這邊站長的教學寫的很清楚了
7 }+ s5 }; }4 [& ]謝謝
/ I, w9 E2 q. A8 P; l+ [
: j3 x, m- U0 L, T  \" C但是我照做之後5 s7 }+ u$ o, i/ |
不能連入相簿了( i' x- C( o; N
他告訴我這行有誤
/ c0 R  I% b" J" F4 l$ u' w$sql = "SELECT user_id from `cpg134_users`  ...

TOP

發新話題