【发布时间】:2015-07-08 15:46:32
【问题描述】:
嗨朋友们,我收到了这个错误,请告诉我如何解决这个错误。我的 htaccess 文件的 htaccess 是这样的:
#Options +FollowSymLinks -MultiViews
#RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^ - [L]
RewriteRule ^friends/([\w-]+)/?$ /friends.php?username=$1 [L,QSA]
RewriteRule ^followers/([\w-]+)/?$ /followers.php?username=$1 [L,QSA]
RewriteRule ^settings/([\w-]+)/?$ /settings.php?username=$1 [L,QSA]
RewriteRule ^messages/([\w-]+)/?$ chat.php?message_username=$1 [L,QSA]
RewriteRule ^following/([\w-]+)/?$ following.php?username=$1 [L,QSA]
RewriteRule ^following/([\w-]+)/([0-9]+)/?$ following.php?username=$1&page=$2 [L,QSA]
RewriteRule ^followers/([\w-]+)/?$ followers.php?username=$1 [L,QSA]
RewriteRule ^followers/([\w-]+)/([0-9]+)/?$ followers.php?username=$1&tpage=$2 [L,QSA]
RewriteRule ^photos/([\w-]+)/?$ userphotos.php?username=$1&page=$2 [L,QSA]
RewriteRule ^(.*/([a-zA-Z0-9_-]+)|([a-zA-Z0-9_-]+))$ profile.php?username=$1 [L,QSA]
未找到
在此服务器上找不到请求的 URL /profile/following/demo。
prototype.kofendurance.com 端口 80 上的 Apache/2.2.15 (CentOS) 服务器
我也得到同样的错误所有 htaccess RewriteRule。
【问题讨论】:
-
你应该取消第一行的注释,至少
RewriteEngine On和RewriteBase /(只需删除行首的#) -
@devsymediane 然后我收到此错误:
Not Found The requested URL /following.php was not found on this server. -
你的最后一条规则是启动并重定向到
/profile.php?username=profile/following/demo -
您的文件(如following.php)是否在子文件夹中?如果是这种情况,您应该调整 RewriteBase(如
RewriteBase /myfolder) -
@devsymediane 感谢您的回答,但它无法正常工作,因为我没有以下文件夹。这是 .htaccess 设置。那么,如果它有效,那么我能为其他 RewriteRule 做什么?
标签: php regex apache .htaccess mod-rewrite