[英][.htaccess]How to rewrite this url?
I'm still finding difficulty rewriting the htaccess to make the url a bit pretty. 我仍然发现很难重写htaccess来使url变得漂亮。
this is the actual url: 这是实际的网址:
http://mydomain.com/folder/page.php#_=_
I want to rewrite the above to: 我想将以上内容重写为:
http://mydomain.com/folder/page
I tried this approach after following various tutorials but its not working: 在完成各种教程之后,我尝试了这种方法,但是它不起作用:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ hhttp://mydomain.com/folder/page.php#$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ http://mydomain.com/folder/page$1
</IfModule>
I know its wrong but I really don't know how to do it properly. 我知道它的错,但是我真的不知道如何正确地做。
any help is greatly appreciated. 任何帮助是极大的赞赏。 TIA
TIA
#_=_
won't be passed to the server (actually it's not a part of URI). #_=_
不会传递到服务器(实际上,它不是URI的一部分)。
The only way is to do it with JavaScript (on client side) instead of with PHP (on server side): 唯一的方法是使用JavaScript(在客户端)而不是PHP(在服务器端):
if (location.hash === "#_=_") {
location.replace(location.href.replace(/#.+/, ""));
}
But it seems not necessary. 但这似乎没有必要。
Use this 用这个
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^folder/page.php#_=_$ folder/page [L,R=301]
</IfModule>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.