[英]Url rewriting for all identical filenames
我想重写我的所有网址:
http://example.com/folder/40/name/test.php
和
http://example.com/folder/40/test.php
至
http://example.com/test.php
有没有人有办法解决吗?
谢谢
你可以使用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重写
您可以通过PHP轻松完成,但在打开HTML标记之前必须在两个页面中包含此代码。
<?php
$useragent=$_SERVER['HTTP_USER_AGENT'];
header('Location: http://example.com/test.php'); ?>
希望这个能对您有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.