简体   繁体   English

如何使用.htaccess和mod_rewrite重写URL?

[英]How do I rewrite my URLS with .htaccess and mod_rewrite?

I currently have my URLS in this format: 我目前的网址格式如下:

http://www.domain.com/game.php?id=3434&title=title-goes-here http://www.domain.com/game.php?id=3434&title=title-goes-here

I would like the URLs to be written as: 我希望将URL编写为:

http://www.domain.com/ID/title-goes-here.html http://www.domain.com/ID/title-goes-here.html

How would I go about doing this? 我将如何去做呢?

Try this: 尝试这个:

Create an .htaccess file in the root of your website and put this in it. 在网站的根目录中创建一个.htaccess文件,并将其放入其中。

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)\.html$ /game.php?id=$1&title=$2 [L]

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

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