重写规则的Apache找不到网址是什么? [英] Rewrite rule for Apache not finding URL?

查看:133
本文介绍了重写规则的Apache找不到网址是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用我从 rcs20 在我的当我将此条目添加到我的.htaccess文件我看到错误404未找​​到previous帖子

 选项+了FollowSymLinks
RewriteEngine叙述上
重写规则^成员\  - ([0-9] +)\  - ?([^ /])\ HTM(L)$ view_profile.php ID = $ 1 [NC,L]
 

我通过它的网址是:

 的mysite /件-8222-jane.html
 

任何想法,为什么这可能发生。我的老重写规则正常工作:

 重写规则view_profile =(。*)$ view_profile.php?ID = $ 1
 

解决方案

发现:

+ 标志需要被添加到 [^ /] => ( [^ /] +)

 选项+了FollowSymLinks
RewriteEngine叙述上
重写规则^成员\  - ([0-9] +)\  - ?([^ /] +)\ HTM(L)$ view_profile.php ID = $ 1 [NC,L]
 

您也可以在成员-8222-jaane.html 通过使用$喜欢添加额外的字符

 重写规则^成员\  - ([0-9] +)\  - ?([^ /] +)\ HTM(L)$ view_profile.php ID = $ 1和;额外= $ 2 [NC,L]
 

Using the answer I received from rcs20 in my previous post when I add this entry to my .htaccess file I see the error 404 Not Found:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^member\-([0-9]+)\-([^/])\.htm(l)?$ view_profile.php?id=$1 [NC,L]

The URL I'm passing it is:

mysite/member-8222-jane.html

Any idea why this might be happening. My old rewrite rule works fine:

RewriteRule view_profile=(.*)$ view_profile.php?id=$1 

解决方案

found it:

The + sign needs to be added to [^/] => ([^/]+)

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^member\-([0-9]+)\-([^/]+)\.htm(l)?$ view_profile.php?id=$1 [NC,L]

You can also add the extra chars jane in member-8222-jaane.html by using the $2 like:

RewriteRule ^member\-([0-9]+)\-([^/]+)\.htm(l)?$ view_profile.php?id=$1&extra=$2 [NC,L]

这篇关于重写规则的Apache找不到网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆