我真的对我正在做的事情一无所知。抱歉。
这就是我重写这些URL的方法:
http://example.com/foo/bar/news/1-category-name/2-item-name
http://example.com/foo/bar/news/1-category-name
进入这些:
http://example.com/foo/bar/news.php?newsID=2
http://example.com/foo/bar/news-categories.php?categID=1
分别
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /foo/bar
RewriteRule ^news\/([^\/]+)/([0-9]+)-([^\/]+)$ news.php?newsID=$3
RewriteRule ^news\/([0-9]+)-([^\/]+)$ news-categories.php?categID=$1
</IfModule>
但每当我尝试这个URL:
http://example.com/foo/bar/news/16-news-category-1/11-title
它总是返回一个 404
错误:
在此服务器上找不到请求的URL /foo/bar/news.html/16-news-category-1/11-title
为什么要试图找到 news.html
?我究竟做错了什么?
我不知道这是否相关,但是 example.com
是 虚拟 (我真的不知道这个词)。也可以通过访问实际文件 http://real-domain.com/qux/
。所以你会这样做 http://real-domain.com/qux/foo/bar/news/1-category-name/2-item-name
到达,得到 2-item-name
。
说这个脚本实际上是在我的开发机器上运行也有帮助吗?
Development:
PHP v5.3.5
Apache v2.2
Live:
PHP v5.3.6
Apache v2.2