3
我想,每一個用戶都有一個配置文件,網址是這樣的:htaccess的+ modrewrite問題
www.example.com/username
我創造了這個htaccess的:
RewriteEngine on
RewriteRule ([^/]+) profile.php?username=$1 [L]
,但我得到的錯誤與CSS和JS文件。
我有什麼在htaccess的寫?
我想,每一個用戶都有一個配置文件,網址是這樣的:htaccess的+ modrewrite問題
www.example.com/username
我創造了這個htaccess的:
RewriteEngine on
RewriteRule ([^/]+) profile.php?username=$1 [L]
,但我得到的錯誤與CSS和JS文件。
我有什麼在htaccess的寫?
你一般應排除所有實際文件和目錄,因爲這將處理CSS/JS /圖像/任何你想提供:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ profile.php?username=$1 [L]
Exclue js和css與RewriteCond
。我認爲這應該這樣做:
RewriteEngine On
RewriteCond %{REQUEST_URI} ! \.(js|css)$ [NC]
RewriteRule ([^/]+) profile.php?username=$1 [L]
如果你有圖片爲好,加上其擴展
RewriteCond %{REQUEST_URI} ! \.(js|css|jpg|gif|ico|png|whatever)$ [NC]