我有一個問題只有一個在重寫規則的htaccess頁:的.htaccess只有一個規則被不工作
http://www.snes-fr.net/staff.html頁面無法正常工作(404),但所有其他的。
staff.php夾中:http://www.snes-fr.net/pages/staff.php
的.htaccess行:RewriteRule ^staff\.html$ index.php?page=staff [L]
,但這個環節不工作:http://www.snes-fr.net/staff.html 這一項工作:http://www.snes-fr.net/cgu.html
RewriteRule ^cgu\.html$ index.php?page=cgu [L]
代碼顯示頁面
$page = @htmlspecialchars($_GET['page'], ENT_QUOTES);
if(is_file('pages/'.$page.'.php'))
{
require('pages/'.$page.'.php');
}
你有什麼線索嗎?謝謝
編輯:的htaccess:
SetEnv PHP_VER 5_4
ErrorDocument 404 http://www.snes-fr.net/404.html
RewriteEngine on
Options +FollowSymlinks
SetEnv REGISTER_GLOBALS 1
SetEnv MAGIC_QUOTES 0
RewriteCond %{HTTP_REFERER} decerto\.fr [NC]
RedirectMatch seeother ^/dossier-super-nintendo_([0-9]+)_(.*)\.html$ http://www.snes-fr.net/tests.html
#REECRITURE
RewriteRule ^staff\.html$ index.php?page=staff [L]
RewriteRule ^cgu\.html$ index.php?page=cgu [L]
RewriteRule ^contact\.html$ index.php?page=contact [L]
RewriteRule ^404\.html$ index.php?page=404 [L]
RewriteRule ^index\.html$ index.php [L]
...
我的一切都工作後重寫規則!
我在localhost服務器上測試了這個重寫規則,它實際上工作。可能你的另一部分'.htaccess'搞亂了。你能完全展示給我們嗎? –
除了Guilherme的評論:你爲什麼在這裏使用htmlspecialchars?你應該添加一個檢查if(realpath('pages /'.$ page。'。php')=='pages /'.$ page。'。php')'來拒絕路徑遍歷,也就是做'索引。 php?page = ../../some-other-php'不可能 –
謝謝你的建議,我改了!並添加htaccess –