开发者

nice url with apache and php

开发者 https://www.devze.com 2023-01-04 19:21 出处:网络
I have urls like /story.php?id=31 I want 开发者_运维问答to show it as /31.html How?mod_rewrite is the answer. See e.g. this guide or this one.

I have urls like /story.php?id=31

I want 开发者_运维问答to show it as /31.html How?


mod_rewrite is the answer. See e.g. this guide or this one.


/31.html -> /story.php?id=31 (rendering your links is another - and easier - issue)

RewriteEngine on
RewriteRule   ^/([0-9]+)\.html$ /story.php?id=$1 [L,QSA]


You'll want to use Apache's mod_rewrite engine.

The rule you are looking for would look something like this:

RewriteEngine On
RewriteBase /
RewriteRule ^([0-9]+)\.html$ story.php?id=$1 [L]


Using apache and mod_rewrite, a possible sollution could be:

RewriteEngine On
RewriteRule ^([0-9]+)\.html /story.php?id=$1 [NC,QSA,L]
0

精彩评论

暂无评论...
验证码 换一张
取 消