如何MOD-重写这个URL htaccess的? [英] How to mod-rewrite this URL in htaccess?

查看:123
本文介绍了如何MOD-重写这个URL htaccess的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下URL结构:

http://localhost/sitename/views/www/page.php

我想为page.php显示出来,即使用户输入:

I would like for page.php to show up even if the user enters:

http://localhost/page

如何使用htaccess的做到这一点?请记住,有很多不同的页面会在同一个目录级别page.php,我想对所有的人都可以访问相同的方式。

How to do this using htaccess? Please keep in mind that a lot of different pages will be in the same directory level as page.php and I would like for all of them to be accessible the same way.

推荐答案

我会尝试以下方法:

RewriteEngine on

RewriteRule ^([^/]*)$ /sitename/views/www/$1.php [L]

这将显示预期的页面,没有重定向。替换 [L] [R =永久,L] 如果你想重定向浏览器。

This will display the expected page with no redirect. Replace [L] with [R=permanent,L] if you wish the browser to be redirected.

这篇关于如何MOD-重写这个URL htaccess的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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