简体   繁体   English

使用GET变量htaccess重定向页面

[英]Redirect page with GET variable htaccess

Firstly,Thanks for reading this. 首先,感谢您阅读本文。 How to rewrite the url , in htaccess 如何在htaccess中重写url

For example 例如

wwww.domain.com/home?name=MuhdNazmi <---OLD URL
wwww.domain.com/home/MuhdNazmi <---NEW URL

name is a get variables, 名称是一个获取变量,

I dont need put .php , since it code for not showing > .php 我不需要放.php,因为它的代码用于不显示> .php

Try: 尝试:

RewriteCond %{THE_REQUEST} \ /home\?name=([^&\ ]+)
RewriteRule ^ /home/%1? [L,R=301]
RewriteRule ^home/([^/]+)$ /home?name=$1 [L,QSA]

RewriteRule上的RewriteEngine ^ home /([[^ /] *)。php $ / home?name = $ 1 [L]

If it is a one on redirect then you can follow the below example for you redirect 如果是重定向,则可以按照以下示例进行重定向

RewriteEngine on
    RewriteCond %{QUERY_STRING} name=MuhdNazmi$ [NC]
    RewriteRule ^home/$ /home/MuhdNazmi? [L]

If you want to define it as a generic rule for all the query string parameter modify the above code as 如果要将其定义为所有查询字符串参数的通用规则,请将上面的代码修改为

RewriteEngine on
    RewriteCond %{QUERY_STRING} name=(.*)$ [NC]
    RewriteRule ^home/$ /home/%1? [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM