htaccess的重定向与参数的所有网页重定向、参数、网页、htaccess

2023-09-02 01:16:05 作者:Lovingd(噬心人)

我需要在我的网站的所有网页重定向到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]
 
js 怎么URL 重定向,和获取重定向之后的地址以及参数

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

  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