重定向使用mod_rewrite [英] Redirect using mod_rewrite

查看:112
本文介绍了重定向使用mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Options +FollowSymLinks
Options +Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^haveg/employer/([0-9]+)/(.*) haveg/employer.php?msg_id=$1

它工作正常,当我使用

It works fine when i use

http://localhost/haveg/employer/7003/the-message-title
or
http://localhost/haveg/employer/7003/

现在的问题是这里的http://本地主机/ haveg /雇主/ 7003 ,因为我删除了正斜杠结尾。它给找不到页面错误。

The problem is here http://localhost/haveg/employer/7003 because i removed the forward slash at the end. it gives page not found error.

推荐答案

重写规则^ haveg /雇主/([0-9] +)/?(。*)haveg / employer.php?MSG_ID = $ 1

RewriteRule ^haveg/employer/([0-9]+)/?(.*) haveg/employer.php?msg_id=$1

我想加一个问号应该允许它来搭配。

I think adding a questionmark should allow it to match.

这篇关于重定向使用mod_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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