2011-07-11 66 views
0

我有一个网站xxxxx.com和动态内容的URL结构是 xxxxx.com/tours/index.php?tourid=x 其中tour id是关键,x是值MOD重写查询字符串重定向问题

我想出了一个使用国防部重写将流量重定向到上述网址可 xxxxx.com/x 其中x是价值

这个问题的.htaccess规则是: 当我转到主要的网址即。 www.xxxxx.com/或www.xxxxx.com/something.html它也将其重定向到tours/index.php?

如何将请求重定向到/tours/index.php?tourid=x而不是所有内容?

这是我现在有:

RewriteEngine On 
RewriteRule ^([^/]*)$ /tours/?tourid=$1 [L] 

我很欣赏的答复。谢谢。

回答

0

你可以将规则应用于仅文件和文件夹,其实际上并不在文件系统中存在:

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([^/]*)$ /tours/?tourid=$1 [L] 
+0

太棒了!非常感谢你。 – kinsey

0

这只会将'xxxxx.com/tours/index.php?tourid=x'网址专门定位到/ x,如果您还需要别的东西,请发表评论。

RewriteEngine On 
RewriteRule ^/tours/index.php\?tourid=(.*) /$1 [L] 
+0

哥们,谢谢! =] – kinsey