3 回答

TA貢獻1825條經驗 獲得超6個贊
試試這個(如果你想使用 images/js/css/.. 稍后也很有用)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.(gif|jpg|png|jpeg|css|js|swf)$ /$1.$2 [END,NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
提示:您可以組合大小寫“/”和”
<?php
$request = $_SERVER['REQUEST_URI'];
echo $request;
switch ($request) {
case '/' :
case '' : // you can combine the cases '/' and ''
require __DIR__ . '/views/home.php';
break;
case '/about' :
require __DIR__ . '/views/about.php';
break;
default:
http_response_code(404);
require __DIR__ . '/views/404.php';
break;
}

TA貢獻1813條經驗 獲得超2個贊
將 .htaccess 規則更改為
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

TA貢獻1826條經驗 獲得超6個贊
打開位于此處的 httpd-vhosts.conf 文件:C:\XAMPP\apache\conf\extra\httpd-vhosts.conf
在目錄標記下添加以下行:
AllowOverride All
- 3 回答
- 0 關注
- 150 瀏覽
添加回答
舉報