简体   繁体   English

SEO友好的网址说明?

[英]SEO friendly url explanation?

I've did some research in how to rewrite my url with htaccess for an SEO friendly url, but I have a questions: 我对如何使用htaccess重写我的URL进行了SEO友好的URL进行了研究,但是我有一个问题:

When i rewrite from index.php?news=1 to /news/1 would my $_GET['news'] still work? 当我从index.php?news = 1重写到/ news / 1时,我的$_GET['news']仍然可以工作吗? I can't seem to find an explanation on that. 我似乎找不到对此的解释。 I want to be sure before I'll start implementing it into my website. 在开始将其实施到我的网站之前,我想确定一下。

Thanks! 谢谢!

Yes, that will work as expected. 是的,这将按预期工作。

Specifically, mod_rewrite 's behavior with regards to existing query strings can be surprising. 具体来说,关于现有查询字符串的mod_rewrite行为可能令人惊讶。 As an example, let's take the following rule, which converts the URL you supplied: 例如,让我们采用以下规则,该规则将转换您提供的URL:

 index.php?news=1 to /news/1

page name will be accessible through $_GET['news'] . 页面名称可以通过$_GET['news']

When i rewrite from index.php?news=1 to /news/1 would my $_GET['news'] still work? 当我从index.php?news = 1重写到/ news / 1时,我的$ _GET ['news']仍然可以工作吗?

Yes . 是的 $_GET['news'] is set because you have hardcoded news=1 into the rewritten query string. $_GET['news']的原因是您已将news=1硬编码到重写的查询字符串中。

If you have additional query parameters, it depends . 如果您还有其他查询参数, 则取决于 If you've used the QSA (query string append) flag then yes , otherwise $_GET['param'] would not be set in the URL: 如果您使用了QSA (查询字符串追加)标志, $_GET['param'] yes ,否则$_GET['param']不会在URL中设置:

/news/1?param=2

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

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