使用.htaccess的基于日期和名称的友好URL [英] Date and name based friendly URL using .htaccess

查看:44
本文介绍了使用.htaccess的基于日期和名称的友好URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算从在wordpress.com上拥有博客转变为在自己的服务器上托管自己的站点.自然,我想保留来自wordpress的链接结构,以便在WWW中断时没有指向我博客的链接.

I'm planning on switching from having my blog on wordpress.com to having it on my own site hosted on my own server. Naturally I want to preserve the link structure from wordpress so that no links to my blog out there on the WWW break.

所以我的问题是,如何获得以下友好网址

So my question is, how do I get the following friendly URL

http://example.com/yyyy/mm/dd/post-name

映射到某些结构,例如

http://example.com/index.php?page=bla-bla

在我的服务器上使用.htaccess吗?

on my server using .htaccess?

标识符bla-bla可以是简单的整数id,还是必须同时包含日期和名称,即yyyy-mm-dd-post-name?

Can the identifier bla-bla be a simple integer id, or does it have to include both date and name, that would be yyyy-mm-dd-post-name?

谢谢.

感谢您的快速答复.不过,我的问题还有一些补充:我目前未使用wordpress.org,因此我没有可为我生成文件的控制面板.至少我认为不是.而且我也不会在自己的服务器上使用wordpress.

Thank you for your quick replies. A few additions to my question though: I'm not currently using wordpress.org, so I don't have a control panel that can generate the file for me. At least I think not. And I'm also not going to use wordpress on my own server.

推荐答案

您可以根据需要进行以下工作:将其放入.htaccess文件中.

You can make following work as you require .. put it in a .htaccess file.

# Options +FollowSymLinks  
# RewriteEngine On  
#   
# RewriteCond %{SCRIPT_FILENAME} !-d  
# RewriteCond %{SCRIPT_FILENAME} !-f  
#   
# RewriteRule ^page/(\d+)*$ ./page.php?id=$1 

阅读所有详细信息.. 点击此处阅读友好且漂亮的网址"

To read all of the details .. click here to read "friendly and pretty urls"

这篇关于使用.htaccess的基于日期和名称的友好URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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