我想重写我的所有网址:
http://example.com/folder/40/name/test.php
和
http://example.com/folder/40/test.php
到
http://example.com/test.php
有没有人有解决方案?
感谢
答案 0 :(得分: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]
答案 1 :(得分:0)
您可以通过PHP轻松完成,但在打开HTML标记之前必须在两个页面中包含此代码。
<?php
$useragent=$_SERVER['HTTP_USER_AGENT'];
header('Location: http://example.com/test.php'); ?>
希望这会对你有帮助!