看板 Web_Design 關於我們 聯絡資訊
※ 引述《yanli2 (Yan)》之銘言: : ※ 引述《andrew43 (Myrmarachne)》之銘言: : : 我的 .htaccess 如下: : : ### : : Options FollowSymLinks : : RewriteEngine On : : RewriteRule ^(.*)/index.html$ http://localhost/index.php?page=$1 [NC,L] : : ### : : 如此確實可以以 http://localhost/x/index.html (短網址) : : 得到 http://localhost/index.php?page=x (長網址) : : 但是每次在瀏覽器上輸入短網址, : : 網址列也就直接跳到長網址,並輸出長網址的內容了。 : : 而我希望的是若輸入短網址,可以得到長網址的內容,但網址列仍顯示短網址。 : : 請問我該往什麼方向或設定來檢查? : : Server version: Apache/1.3.41 (Darwin) : 修改一下你的 RewriteRule : 改成 : RewriteRule ^(.*)/index.html$ /index.php?page=$1 : 試看看 這樣他就直接執行後面這個程式了,而不是使用轉頁的方式 : EX: http://34c.cc/BBS_0 先進你好。 我按你的方式,結果在 localhost(Apache/1.3.41 (Darwin))上竟變成 404 Not Found。 但我在遠端的 server 上卻成功了。 很感謝你的幫助,但不知道我自己的 localhost 為什麼不成功? 也許在自己電腦的 httpd.conf 有我該修改之處,請你指教,可能往什麼方向修改? 再次感謝你。 -- http://apansharing.blogspot.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.125.203.33
chph:你要設 RewriteBase 03/02 00:03
andrew43:謝謝chph,成功了。 03/02 00:20
yanli2:因為他只會讀取你網址跟目錄下方的index.php 03/02 00:31
yanli2:所以你再localhost測試時 你的程式可能不是放在根目錄下 03/02 00:31
yanli2:修正3F推文 跟目錄→根目錄 03/02 00:32