简体   繁体   English

htaccess用URL中的多个PHP变量重写URL

[英]htaccess url rewriting with multiple php vars in url

I need to create friendly urls for my website 我需要为我的网站创建友好的网址

need to change this url: 需要更改此URL:
http://sitename.com/pn?title=1100متر+ویلایی+گلابدره&id=117 http://sitename.com/pn?title=1100متر+ویلایی+گلابدره&ID = 117

to this url, that contains utf-8 characters to 此网址,其中包含utf-8字符
http://sitename.com/1100متر+ویلایی+گلابدره http://sitename.com/1100متر+ویلایی+گلابدره

I also need my variables like id, by using htaccess rewriting can i stil use them ? 我还需要像id这样的变量,通过使用htaccess重写,我是否可以使用它们?

is there a good doc that i can learn more about url rewriting ? 有没有一个好的文档,我可以了解有关URL重写的更多信息?
and is url rewriting good for website seo ? 网址重写对网站seo有益吗?


THANKS 谢谢

Try it like this, I am unsure about the character you are passing and also you need to pass id in url too for rewriting. 像这样尝试,我不确定您要传递的字符,并且也需要在URL中传递id来进行重写。 Please let me know if it works. 请让我知道它是否有效。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/([\d]+)$ pn?title=$1&id=$2 [QSA,NC,L]

Here is your code 这是你的代码

 var currentURL = window.location.href; var currentDomain = window.location.hostname; function getParameterByName(name, url) { if (!url) { url = window.location.href; } name = name.replace(/[\\[\\]]/g, "\\\\$&"); var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/\\+/g, " ")); } window.history.pushState('page',document.title,getParameterByName('title')) 

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

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