的.htaccess URL重写有一个和两个查询字符串瓦尔 [英] .htaccess URL rewrite with one and two query string vars

查看:145
本文介绍了的.htaccess URL重写有一个和两个查询字符串瓦尔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想URL重写的第一次,我有哪些需要重写以下网址:

  http://domain.com/resorts.php?countryname=Portugal
http://domain.com/rss.php?destination=Torremolinos&itemtype=rfamily
 

我已经写在我的.htaccess文件如下:

 选项+了FollowSymLinks
RewriteEngine叙述上

重写规则/countryname/(.*)/ resorts.php?COUNTRYNAME = $ 1
重写规则/destination/(.*)/itemtype/(.*)/ rss.php目的地= $ 1安培;的ItemType = $ 2
 

但是,当我尝试以下方法,我不断收到找不到网址。请能有人指出我可能做错了什么?提前很多感谢。

  http://domain.com/countryname/Portugal
http://domain.com/destination/Torremolinos/itemtype/rfamily
 

解决方案

您可以使用此:

 选项+了FollowSymLinks
RewriteEngine叙述上
的RewriteBase /
重写规则COUNTRYNAME /(.*)/? resorts.php?COUNTRYNAME = $ 1 [NC,L]
重写规则目的地/(.*)/的ItemType /(.*)/? ?rss.php目标= $ 1安培;的ItemType = $ 2 [NC,L]
 

I'm trying URL re-writing for the first time and I have the following URLS which need rewriting:

http://domain.com/resorts.php?countryname=Portugal
http://domain.com/rss.php?destination=Torremolinos&itemtype=rfamily

I've written the following in my .htaccess file:

Options +FollowSymLinks
RewriteEngine on

RewriteRule /countryname/(.*)/ resorts.php?countryname=$1
RewriteRule /destination/(.*)/itemtype/(.*)/ rss.php?destination=$1&itemtype=$2

But when I try the following, I keep getting URL not found. Please can someone point out what I may be doing wrong? Many thanks in advance.

http://domain.com/countryname/Portugal
http://domain.com/destination/Torremolinos/itemtype/rfamily

解决方案

You can use this:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule countryname/(.*)/? resorts.php?countryname=$1 [NC,L]
RewriteRule destination/(.*)/itemtype/(.*)/? rss.php?destination=$1&itemtype=$2 [NC,L]

这篇关于的.htaccess URL重写有一个和两个查询字符串瓦尔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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