如何为基于 PHP 的站点制作无扩展名的 url? [英] How to make extension-less url for a PHP based site?

查看:26
本文介绍了如何为基于 PHP 的站点制作无扩展名的 url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否必须将每个文件放在不同的文件夹中?

Do I have to put every file in a different folder?

喜欢:

about-us/about-us.php
profile/profile.php

或者是否有其他自动解决方案.

or is there any other automatic solution.

我想转换

http://sitename.com/about-us/about-us.php

http://sitename.com/about-us

推荐答案

你想要 漂亮的 URL 重写.

该文章中的 Apache .htaccess 示例:

An Apache .htaccess examples from that article:

  • 漂亮的网址:/browse/animals-24/cats-76.html

丑陋的网址:/browse.php?category=24&subcategory=76

.htaccess:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^browse/[A-Z0-9_-]+-([0-9]+)/[A-Z0-9_-]+-([0-9]+)\.html$ browse.php?category

这篇关于如何为基于 PHP 的站点制作无扩展名的 url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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