htaccess的重定向与参数的所有网页 [英] htaccess redirect all pages with parameters

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

问题描述

我需要在我的网站的所有网页重定向到home.php与查询字符串和页面参数

例子:

  www.site.com/abcd
 - > www.site.com/home.php?page=abcd

   www.site.com/abcd/file.php
 - > www.site.com/home.php?page=abcd/file.php

   www.site.com/file.php?a=b&c=d
 - > www.site.com/home.php?page=file.php&args="a=b&c=d
 

解决方案

您可以在你的.htaccess文件把这个:

  RewriteEngine叙述上
重写规则^(。+)$ home.php?页= $ 1 [QSA,L]
 

这会做你想要什么,除了参数传递,他们将在那里原始形式展现出来:

  www.site.com/file.php?a=b&c=d  - > www.site.com/home.php?page=file.php&a=b&c=d
 

I need all pages on my site to be redirected to home.php with query string and the page as parameter

examples:

   www.site.com/abcd
-> www.site.com/home.php?page=abcd

   www.site.com/abcd/file.php
-> www.site.com/home.php?page=abcd/file.php

   www.site.com/file.php?a=b&c=d
-> www.site.com/home.php?page=file.php&args="a=b&c=d"

解决方案

You could put this in your .htaccess file:

RewriteEngine On
RewriteRule ^(.+)$ home.php?page=$1 [QSA,L]

This will do what you want, except for the parameters passed, they will show up in there original form:

www.site.com/file.php?a=b&c=d -> www.site.com/home.php?page=file.php&a=b&c=d

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

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