【发布时间】:2016-10-03 15:01:37
【问题描述】:
我需要用 title 和 id 动态重写 url。我想动态制作网址
http://dev.example.com/beweb/iphone-8.html
代替
http://dev.example.com/beweb/newsdetails.php?id=8&title=iphone
当我运行上面的 URL 时,它会动态生成我需要的内容.. 但出现错误
" 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]
请帮帮我。
【问题讨论】:
标签: .htaccess mod-rewrite url-rewriting friendly-url