1
我想改變URL更改URL格式
http://localhost/Self-Content/img.php?v=YQHsXMglC9A&fmt=hqdefault.jpg
到 http://localhost/Self-Content/bUTdUaVmj8o/mqdefault.jpg
如何我在PHP
我試試這個.htaccess
RewriteEngine On
RewriteCond %{THE_REQUEST} /img\.php\?v=([^\s]+) [NC]
RewriteCond %{THE_REQUEST} /img\.php\&fmt=([^\s]+) [NC]
RewriteRule^/%1? [NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ img.php?v=$1 [QSA,L,NC]
RewriteRule ^([^/]+)/?$ img.php?v=&fmt=$1 [QSA,L,NC]
我使用WAMP但是當我試試這個代碼我得到這個錯誤
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
謝謝ANS當我在'的.htaccess中添加此代碼'但我在WAMP面臨'500內部服務器Error'我所能知道 – Alish
這段代碼中的任何內容都不會導致500,我在我的Apache上測試過它們。你必須啓用'mod_rewrite',並檢查你的'error.log'是否有500錯誤的確切原因。 – anubhava
謝謝親愛的工作很好,非常感謝 – Alish