创建没有扩展名的 url,如 wordpress [英] Creat urls without extensions like wordpress

查看:18
本文介绍了创建没有扩展名的 url,如 wordpress的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何使网站上的 url 看起来像 wordpress 漂亮的永久链接,或者确切地说没有扩展名,但又不必在服务器上创建目录.

Hi I was wondering how to make the url on a website look like wordpress pretty permalinks or without extensions to be exact, but without having to make directories on the server.

我想在 mysql 中放置一个表,比如 'url'、'meta' 和 'id',而不是总是使用 htaccess 调用 index.php 并获取 url 的 uri 并相应地重定向.

I was thinking of putting a table in mysql of say 'url', 'meta' and 'id' and than always calling the index.php with htaccess and grab the uri of the url and redirect accordingly.

这是最好的方法还是一个可怕的想法=).这是否可以通过谷歌仍然能够抓取页面的方式来完成,或者是否应该在其中使用 index.php 创建目录.

Would this be the best way or is it a horrible idea =). Can this be done in a way that google would still be able to crawl pages or should directories be made with index.php in them.

谢谢指点

推荐答案

难道你不能做一些类似于 Kohana 中 URL 溢出的事情 ( http://kohanaframework.org/3.0/guide/kohana/routing)?基本上,你让用户输入他们想要的任何 URL,然后你在 PHP 代码中手动解析这个 URL 并重定向到正确的控制器/PHP 文件/类,无论你选择什么系统.

Couldn't you do something similar to the URL's overflow in Kohana ( http://kohanaframework.org/3.0/guide/kohana/routing )? Basically, you let the user type any URL they want, then you parse this URL manually in your PHP code and redirect to the right controller / PHP file / class, whatever system you choose.

如果输入的 URL 无效,只需抛出 404 错误或重定向到您的错误页面.

If the input URL is invalid, just throw a 404 error or redirect to your error page.

这篇关于创建没有扩展名的 url,如 wordpress的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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