htaccess的重写URL一个问号“?”只为1特定的网址(.htaccess rewrite URL with a question mark “” only for 1 specific URL)

   IT问题网   2019-01-31 00:00:00

问 题

我已经几个星期前开始的话题。 不过,我现在有一个新的问题,这是非常相似的老问题:<一href="http://stackoverflow.com/questions/18543194/htaccess-rewrite-url-with-a-question-mark">.htaccess ?&一个问号&quot重写url

我的目标是这个网址:

/ mysite的/组件/用户/?查看=登记
 

重写到这个新的url:

 的mysite / registration.html
 

我现在的的.htaccess 得到这个code:

 的rewritebase / mysite的

的rewritecond%{query_string} ^视图=(。*)$
重写规则^组件/用户/?$%1.html? [r = 301,l]
 

它的工作非常细。

但后来我发现,这个配置担心,开始喜欢这一切网址:

/ mysite的/组件/用户/?查看=
 

例如这个配置也将涉及这样一个网址:

/ mysite的/组件/用户/?查看=提醒
 

这是我不想要的东西。

我只希望这个url重写:

 本地主机/ mysite的/组件/用户/?查看=登记
 
解决方案
 的rewritebase / mysite的

的rewritecond%{query_string} ^视图=(注册)$ [nc]
重写规则^组件/用户/ $%1.html? [r = 301,l]
 

如果你想让它仅适用于报名工作则可以指定,而不是一个包罗万象的正则表达式。

同时请记住,因为你有一个全球性的永久重定向了它,你可能需要清除浏览器缓存或使用不同的浏览器,即时看到的变化。

标签:重写一个问号特定网址



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

使用mod_rewrite可以同时去除PHP扩展和干净的GET网址(Use mod_rewrite to remove .php extension and clean GET urls concurrently)

problem this is what i've tried till now: re ...

可有人提醒我在正确的方向上使用mod_rewrite?(Can someone prompt me in the right direction to use mod_rewrite)

problem i am a bit new to this but i am trying to learn. ...

请ppended在请求URI字符串$ P $(Keep the string prepended in request uri)

problem i am building a wordpress website with two langua ...

它是安全的拒绝访问.ini文件在.htaccess?(Is it safe to deny access to .ini file in .htaccess)

problem i have a .ini file with sensitive information in ...

如何删除%的EN codeD斜杠使用的.htaccess规则?(How can I remove percent encoded slashes using .htaccess rule)

problem i want to "catch" incoming urls that ...

htaccess的配置与符号链接和索引文件工作不正常(.htaccess config with symbolic links and index files not working as expected)

problem like a lot of web developers, i like to use .htac ...

htaccess的国防部重写到子域名(htaccess mod-rewrite to subdomain)

problem i'm using the following to redirect w ...

字preSS的.htaccess WWW。不逼(Wordpress .htaccess www. not forcing)

problem i'm trying to force www. on all the pages of my s ...

htaccess的是使用别名的URI时忽略(.htaccess is ignored when using an aliased URI)

problem i am using mod_rewrite to route all requests to i ...

自定义错误页403 PHP(Custom Error 403 Page PHP)

problem i created a .htaccess inside a direct ...

的.htaccess - 服务器错误(.Htaccess - Server error)

problem i'm getting the following error the ...

特殊字符和放大器; URL重写(Special Characters &amp; URL Rewriting)

problem i am currently working on an applicat ...

htaccess的 - 如何重定向所有的URL url.php除了index.php文件(.htaccess - How to redirect all urls to url.php except index.php)

problem rewriteengine on# turn on the rewriti ...

如何获得.htaccess文件与Apache虚拟主机工作(How to get .htaccess files working with Apache VirtualHost)

problem my problem is that my .htaccess file ...

阿帕奇2.4..认证失败..:密码不匹配&QUOT;(Apache 2.4 &quot;..authentication failure..:Password Mismatch&quot;)

problem i am running apache 2.4 in windows se ...

阻止使用htaccess的MOD访问多个IP范围(Blocking multiple ip ranges using mod access in htaccess)

problem i read the guide from apache site but i'm a bit c ...

的Zlib的COM pression搞砸了路径文件中字preSS多站点(Zlib Compression Screwed Up Path to Files in Wordpress Multisite)

problem i'm running a multisite network on wordpress 3.6 ...

$ routeParams硬刷新不工作的角度JS服务器($routeParams Hard Refresh not working on server in angular js)

problem here is my .htaccess file: rewriteen ...

重写规则不工作与加号(+或*)字符(RewriteRule is not working with plus (+ or *) character)

problem rewriterule ^([a-z]).php$/index.phpzi ...

使用基本身份验证(htaccess的)限制访问特定的网址(Using Basic Authentication (htaccess) to restrict access to a specific URL)

problem i need to restrict access to a partic ...