簡體   English   中英

htaccess正則表達式不接受某些特殊字符

[英]htaccess regex not accepting some special characters

我有一個位於http://localhost/dir1/dir2/shift.php的PHP腳本,該腳本將URL作為參數傳遞給我: http://localhost/dir1/dir2/https://google.com但我正在被禁止,您沒有訪問錯誤。 當我刪除:它工作正常。 我已經使用一些在線正則表達式驗證工具檢查了我的正則表達式,它說它應該可以工作,但是不能正常工作

RewriteEngine on
RewriteRule ^dir1\/dir2\/([A-Za-z0-9\!\@\#\$\%\^\&\*\(\)\_\-\+\=\{\}\[\]\;\:\'\"\<\,\>\.\?\|\~\`\s\/\\]+)\/?  dir1\/dir2\/shift.php?url=$1 [L]

任何幫助都會很棒。 謝謝!

不應在URL中使用保留字符。

雖然您可以URL編碼,然后將其作為參數傳遞。 例如:

http://localhost/dir1/dir2/shift.php?
param=http%3A%2F%2Flocalhost%2Fdir1%2Fdir2%2Fhttps%3A%2F%2Fgoogle.com

然后在shift.php您可以先對參數進行URL解碼,然后再使用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM