重写规则的Apache找不到网址是什么?找不到、重写、规则、网址

由网友(惟有ゝ葵花向日倾)分享简介:使用我从 rcs20 在我的当我将此条目添加到我的.htaccess文件我看到错误404未找​​到previous帖子:选项+了FollowSymLinksRewriteEngine叙述上重写规则^成员\ - ([0-9] +)\ - ?([^ /])\ HTM(L)$ view_profile.php ID...

使用我从 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
 
在apache的环境下,tp3.2的项目中重写路由,出现找不到控制器或者找不到模块的问题的解决办法

解决方案

发现:

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

 选项+了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]

阅读全文

相关推荐

最新文章