动态URL重写htaccess的 [英] Dynamic url rewriting htaccess

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

问题描述

我有一个动态的URL重写的一个问题。

I have a problem with dynamic url rewriting.

我有两个不同的网址的,我需要重写的搜索引擎优化的目的。由于这些都不是固定的,而是动态的 - 我可以在htaccess的不只是设置规则如常。另外我也有一对夫妇的固定网址的。

I have two different kind of url’s that I need to rewrite for SEO purposes. Since these are not fixed, but dynamic – I can’t just setup rules in htaccess as usual. In addition I also have a couple of fixed URL's.

所有蛞蝓名称是唯一的,并存储在两个不同的表中我的数据库。

All slug names are unique, and are stored in two different tables in my database.

  1. 产品名称(我有产品一个非常大的列表) http://www.domain.com/a-big-brown-bear.html (应指向view_product.php)

  1. Product names (I have a very large list of products) http://www.domain.com/a-big-brown-bear.html (should point to view_product.php)

类别(类别可以在两个层次) http://www.domain.com/cars/ford.html http://www.domain.com/cars.html

Categories (The categories can be in two levels) http://www.domain.com/cars/ford.html http://www.domain.com/cars.html

(这应该指向view_category.php,和菜单名称的两个级别应沿发送)

(These should point to view_category.php, and both level of menu names should be sent along)

什么是控制动态URL的最佳方式,同时还依靠htaccess的?可能有人知道一个类使用?

What’s the best way of controlling dynamic urls, while still relying on htaccess? Possible someone knows a class to use?

PS:我的问题是不是真的写的规则,但如何来从我的数据库的规则到htaccess的

PS: My problem is not really writing the rules, but how to fetch the rules from my DB into htaccess.

我怕我在做这个比较复杂的,它确实是。所有帮助是AP preciated!

I’m afraid I’m making this more complicated that it really is. All help is appreciated!

在此先感谢,

问候

推荐答案

您有两个基本选择:

  • 捕获所有传入的请求(除了图片,样式表等)到服务器端的前端控制器(PHP,ASP,或者你使用任何服务器端语言),并用做重定向有头(....)。这是最简单和最流行的方式。

  • Catch all incoming requests (except for images, style sheets, etc.) into a server-side front controller (PHP, ASP or whatever server-side language you use), and do the redirection there using header(....). This is the easiest and most popular way.

使用Apache的 RewriteMap指令 指令经常写你映射到文本文件,mod_rewrite的可以看看。

Use Apache's RewriteMap directive to frequently write your maps into text files that mod_rewrite can look up.

RewriteMap指令的变通办法是有益的特殊omptimization情景的许多的流量。通常情况下,机会是你富裕的第一个选项。

The RewriteMap alternative might be beneficial in special omptimization scenarios with lots of traffic. Usually, chances are you're well off with the first option.

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

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