如何重写.htaccess中的单页url [英] how to Rewrite Single Page url in .htaccess
本文介绍了如何重写.htaccess中的单页url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只需要从
http://www.domainname.com/index.php?route=payment/axis/callback
至
http://www.domainname.com/payment/axis/callback
我从堆栈溢出尝试了这两个,我不知道为什么它不起作用
I tried these two from stack overflow, I don't know why its not working
第一个:
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?route=payment/axis/callback [NC,L]
第二个:
RewriteRule ^index.php?route=payment/axis/callback payment/axis/callback [L]
推荐答案
您可以使用h0ch5tr4355的解决方法,也可以尝试以下操作:
You can either use h0ch5tr4355's workaround or you can try this:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^route=payment/axis/callback$
RewriteCond %{SCRIPT_FILENAME} index.php
RewriteRule (.*) /payment/axis/callback [NC,QSD]
如果您不想重写而希望将其重定向到新的URL,则可以添加 R = 301
到RewriteRule的标志。
If you instead of a rewrite would like it to redirect to the new url you can add R=301
to the flags of the RewriteRule.
这篇关于如何重写.htaccess中的单页url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文