Is there any possibility to remove ? and = in html?

问题: I am trying to give pretty url for my html page. I found many answers but they are more related to php. I need to convert this link below, http://localhost/blog.html?id=1...

问题:

I am trying to give pretty url for my html page. I found many answers but they are more related to php. I need to convert this link below,

http://localhost/blog.html?id=1

to

http://localhost/blog/1

I have the .htaccess file for removing html

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^.]+)$ $1.html [NC,L]

Help me to change my url parameters.


回答1:

The examples you find are perfectly valid for you, since this is independent of any higher level logic like php. These rules operate on the level of the http server.

Anyway, here is a rule to get you started:

RewriteEngine on
RewriteCond %{QUERY_STRING} (?:^|&)id=(d+)(?:&|$)
RewriteRule ^/?blog$ blog.html?id=%1 [END,QSD]

In case you get an http status 500 ("internal server error") using this then chances are that you operate a very only version of the apache http server. You will find a hint about an unsopported [END] flag in your http servers error log file in that case. Try replacing the END flag by the older L flag, that probably will work the same, though this depends a bit on your setup.

  • 发表于 2019-03-27 20:28
  • 阅读 ( 137 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除