.htaccess基本mod重写 [英] .htaccess basic mod rewrite

查看:86
本文介绍了.htaccess基本mod重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我才刚刚开始学习如何使用.htaccess文件重写网址。

I am only just starting to learn how to rewrite urls with the .htaccess file.

我将如何更改:

http://www.url.net/games/game_one.php

变为:

http://www.url.net/games/game-one/

这就是我一直在尝试

RewriteRule    ^/games/game-one.php    ^/games/game-one/    [NC,L]


推荐答案

如果您希望人们使用 /游戏/游戏一/ ,必须重写以请求 /game/game-one.php 。因此,与您提出的问题相反。

If you want people to use /games/game-one/ explicitly, you have to rewrite so that it requests /game/game-one.php. So the opposite way around than you have it in your question.

RewriteEngine On
RewriteRule ^games/game-one/$ /games/game-one.php

如果您也想重写其他URL,那么您需要使用与先前答案类似的技术。

If you want to rewrite other URL's too, then you'd need to use a technique similar to the prior answer.

这篇关于.htaccess基本mod重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆