Fixed 404 error on index pages. Also changed to REQUEST_URI instead of SCRIPT_URL.