我需要用標題和ID動態重寫URL。我想讓網址動態代替用標題和ID重寫URL動態
http://dev.example.com/beweb/newsdetails.php?id=8&title=iphone
http://dev.example.com/beweb/iphone-8.html
當我運行上面的網址,以便它dyanamically做什麼,我需要..但得到錯誤
" Not Found
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
The requested URL /beweb/iphone-8.html was not found on this server."
我有使用以下代碼:
RewriteEngine On
RewriteCond %{THE_REQUEST} /beweb/newsdetails.php\?id=([^&\s]+)&title=([^&\s]+) [NC]
RewriteRule^/beweb/%2-%1\.html? [NC,R,L,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^%2-([^.]+)\.html$ /beweb/newsdetails.php?id=$1&title=$2 [QSA,L,NC]
請幫幫我。
我已經把代碼和它的工作..謝謝:)。但其他問題的產生,因爲我想從URL(獲取參數)ID ..現在得到錯誤..你能幫我。 – Jeff
@Jeff只需交換上面的$ 1和$ 2即可。 – hjpotter92
我需要幫助你..你能做到嗎 – Jeff