开发者

rewrite link to make more seo friendly link address

hi I want to rewrite my website links to make it more friendly. weblinks 开发者_JS百科is in this form:

http://www.mysite.com/index.php?content=somepage

to make it more seo friendly, i want to change links as http://www.mysite.com/somepage.html

but declare .htaccess rules so as user click on http://www.mysite.com/somepage.html it is redirected to http://www.mysite.com/index.php?content=somepage

can you help me with related htaccess rule?


Not exactly what you want, but probably nicer. This changes a URL like example.com/hello/ to example.com/?page=hello. (no point specifying index.php in this case)

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteRule ^([A-Za-z0-9-_/\.]+)\/$ /?page=$1 [L]
</IfModule>

If you definitely want the .html (not sure why you would!) try this (untested):

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteRule ^([A-Za-z0-9-_/\.]+).html/$ /?page=$1 [L]
</IfModule>


If you want to change URLs like mysite.com/index.php?product=productname&price=30 to mysite.com/products/productname/30/.

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^products/(.*)/([0-9]+)/$ index.php?product=$1&price=$2
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜