URL重写:如何改写2网址与参数相同的号码?重写、号码、参数、网址

2023-09-02 20:34:57 作者:放下感情你就是王

我已经创造了一些URL重写规则。

它工作正常。

但我有2个页面中包含的URL:

actualites.php ID = XXX和放大器?;别名= XXX

- >结果:ID-alias.php(例如:1-article_name.php)

equipe.php ID = XXX和放大器?;别名= XXX

- >结果:ID-alias.php((例如:1-article_name.php)

这2页是不同的,不一样的设计等。

我想重写这两个不同的网页。我的问题是如何对这些2网址两种不同的规则。

因为他们有两个参数,我已经申请只有一个规则(第一个)

  #become:1,alias.php
重写规则^([0-9] *) - (。*) PHP $ actualites.php猫= $ 1安培;?别名= $ 2 [L]

#become:1- alias.php
重写规则^([0-9] *) -   PHP $ equipe.php id_equipe = $ 1安培(*);?别名= $ 2 [L]
 

解决方案

除非你想添加code。在 actualites.php ,首先无论是参数值的检查猫和别名是有效的,那么你就不能。

如果你想$ C C的$成 actualites.php ,检查参数是有效的,如果没有,发PARAMS到 equipe.php 为id_equipe和别名。否则,你需要的东西添加到URL来验证这要求你实际上映射到。例如:

  http://yourdomain.com/a/1-article.php  - > /actualites.php?cat=1&alias=article
http://yourdomain.com/e/1-article.php  - > /equipe.php?id_equipe=1&alias=article
 
神马搜索广告霸屏的方法 使用高级创意

如果没有这种 / A / / E / ,有没有办法告诉什么映射到。如果你不使用类似的东西,你需要做的所有验证在你的PHP。

I've created some url rewriting rules.

It works fine.

But i have 2 pages with urls like that :

actualites.php?id=xxx& alias=xxx

--> Result : id-alias.php (ex : 1-article_name.php)

equipe.php?id=xxx& alias=xxx

--> Result : id-alias.php ((ex : 1-article_name.php)

These 2 pages are different, not the same design, etc.

I would like to rewrite these 2 different pages. My question is how to have two different rules for these 2 urls.

Since they have 2 parameters, i have only one rule applied (the first one)

#become : 1-alias.php
RewriteRule  ^([0-9]*)-(.*).php$ actualites.php?cat=$1&alias=$2 [L]

#become : 1-alias.php
RewriteRule  ^([0-9]*)-(.*).php$ equipe.php?id_equipe=$1&alias=$2 [L]

解决方案

Unless you want to add code in actualites.php that first checks whether the parameter values for "cat" and "alias" are valid, then you can't.

If you want to code that into actualites.php, check if the parameters are valid, and if not, send the params to equipe.php as "id_equipe" and "alias". Otherwise you'll need to add something to the URL to validate which request you're actually mapping to. For example:

http://yourdomain.com/a/1-article.php  -->  /actualites.php?cat=1&alias=article
http://yourdomain.com/e/1-article.php  -->  /equipe.php?id_equipe=1&alias=article

Without that /a/ or /e/, there's no way to tell what to map to. If you don't use something like that, you'll need to do all validation in your php.