【发布时间】:2014-11-24 09:56:22
【问题描述】:
我已经关注了很多 stackoverflow 问题和谷歌搜索,但我无法正确重写我的 url。 这是我网站的一个简单示例
root-|
|__mydomain-|
|
-|
|__cat1-|__.htaccess
| |__index.php
| |__single.php
|
|__.htaccess
|__index.php // home-page
我的主页包含一个菜单链接:mysite.com/cat1
-> 正确显示“root/cat1/index.php”。
问题1:
对于包含 cat1/post-id/title 的任何其他链接,我需要将 url 重写为 single.php?id=post-id
mysite.com/cat1/123/title
-> should show single php with content of post with id:123
我在 root/cat1/.htaccess 中写的内容
Options +FollowSymLinks
RewriteEngine on
<IfModule mod_rewrite.c>
RewriteBase /cat1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/?$ single.php?id=$1 [L,QSA]
</IfModule>
我得到类似的错误
[Mon Nov 24 13:49:08.549284 2014] [:error] [pid 7144:tid 784] [client 127.0.0.1:21397]
script 'C:/wamp/www/single.php' not found or unable to stat
【问题讨论】:
标签: php regex apache .htaccess mod-rewrite