打印

[CPG] 精簡網址

[CPG] 精簡網址

基本上就是讓5 ?  ?, C0 H, @* G9 |5 I$ K

' n+ J' C$ W4 p3 Rhttp://pic.segaa.net/segaa) |, `- U; l/ A" f0 |  L

  G: }, r7 l, w3 Z+ |; p# ^自動相通於
. ~" f) P& w1 t  T4 A  K0 V' B9 U7 u0 ?$ j- z  X* t7 Q6 I; j
http://pic.segaa.net/index.php?cat=10002# _) ~& s- L2 s  w# f
- c3 u  f' [; G! A: I
讓使用者簡單的記住自己相簿的網址 & ~' h; [6 d8 U

2 x! @" m1 P: i+ U  N編輯index.php 加入以下這些
! e. x) u) O1 ?& R) Mcpg134_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

進階的精簡網址 ... 基本上直接開啟外掛就好了
3 v9 l/ g9 l+ y7 f) a  L# \2 g
  _  J7 t+ N$ I9 W1 a  U
1. 登入管理者之後 -> 設定 -> 允許外掛  點 是 -> 確認
) u( M2 Z# |# g# ~2 {2 K% P
! j5 ?; g3 e0 T3 |" k! v0 {2. 設定 -> ( 外掛管理 ) -> 名稱 Search Engine Friendly URLs v1.0 -> 旁邊有一個 i 的圖形點下去2 x# ^9 m: e8 V! u9 q# j
    選擇覆蓋掉原本的 .htaccess 檔
3 n/ e! [. n& d" D9 x* x6 x, n3 q9 r& y
3. 但是這樣作會讓之前的 http://pic.segaa.net/segaa 失效 , 所以再把上篇的內容加回去6 @; L( F4 M. V: r3 D

" H5 J! U7 u7 n( n% v. g下面是我目前的 .htaccess 檔
: ~* Z" S, i% G7 h" x
% a3 E- b6 q. ^/ Jps.我將 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 太少上論壇看東西了
% }/ f, \6 t" q這邊原本是我用來丟些文件用的
& T+ S+ E0 F- G/ E/ Y. r" M關於這個問題,可能你要直接進資料庫,看你資料庫中所使用的欄位名稱
' r. R3 j4 \! U; ~5 G) i# M6 k( c& D! X# K  z6 x. N, ]

6 t3 y! v0 [7 ~4 C
引用:
原帖由 prolog 於 2006-11-21 02:46 PM 發表
1 H, p8 {9 Q' W8 z4 e" t其實關於精簡網址* D8 q; e; u/ k- f  w% q# R
這邊站長的教學寫的很清楚了4 P- o7 a9 ^% w0 t- l( o
謝謝
$ [/ K3 D# p# z6 B. g7 K7 w
$ n0 T2 z& n3 N) w9 i但是我照做之後
( C* e+ a9 L6 L/ m3 _' _不能連入相簿了
0 r: D3 j+ x+ u1 e! [8 r! L/ X他告訴我這行有誤
' X+ ?3 L, L2 K% R* e( B/ N9 g$sql = "SELECT user_id from `cpg134_users`  ...

TOP

發新話題