0

我想像这样重写我所有的 URL:

http://example.com/folder/40/name/test.php

http://example.com/folder/40/test.php

http://example.com/test.php

有没有人有办法解决吗?

谢谢

4

2 回答 2

2

您可以通过使用 htaccess 来做到这一点。它将重定向所有网址,例如

http://example.com/folder/40/name/test.php
http://example.com/folder/40/test.php

http://example.com/test.php

在 htaccess 文件中添加以下行

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !(img|anyother folders that you want to ignore|anyother folders that you want to ignore|...)
RewriteRule ^(.*)/(.*)/(.*)/test.php$ test.php [L]

RewriteCond %{REQUEST_FILENAME} !(img|anyother folders that you want to ignore|anyother folders that you want to ignore|...)
RewriteRule ^(.*)/(.*)/test.php$ test.php [L]

更多信息Htaccess 重写

于 2013-06-07T07:45:36.567 回答
0

您可以通过 PHP 轻松完成此操作,但您必须在打开 HTML 标记之前在两个页面中都包含此代码。

<?php
$useragent=$_SERVER['HTTP_USER_AGENT'];
header('Location: http://example.com/test.php'); ?>

希望对你有帮助!

于 2013-06-07T06:36:55.160 回答