如何将多个URL重定向到一个文件夹


How to redirect multiple URL to one folder

我正在尝试将多个url重定向到一个文件夹。我试过使用htaccess文件,但它不起作用
我有以下基本url http://super.com/smth/dst

目录结构与相同

-smth
--dst
--...
--whatever

我需要将多个URL重定向到同一个文件夹,在我的情况下是dst

应重定向到此文件夹的URL示例。

http://super.com/smth/dst/level0http://super.com/smth/dst/level1http://super.com/smth/dst/level2http://super.com/smth/dst/levelx

有可能得到这样的吗

如果有任何帮助,我将不胜感激。

有很多来源可以解释.htaccess重定向的一切,所以这里只是你问题的简短答案。

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^smth/dst/([A-Za-z0-9-/_]+)?$ /smth/dst [NC,L]

或者,如果您还需要剪切的文件夹名和查询字符串:

RewriteRule ^smth/dst/([A-Za-z0-9-/_]+)?$ /smth/dst?request=$1&%{QUERY_STRING} [NC,L]

注意,现在smth/dst/之后的所有内容都将传递到$_GET['request']

您可以通过以下方式重定向,请尝试以下代码:-

RewriteEngine on
RewriteBase /
RewriteRule ^smth/dst/(.*)$ smth/dst/index.php [QSA,L]
RewriteRule ^smth/dst/(.*)/$ smth/dst/index.php [QSA,L]

它可能会对你有所帮助。