htaccess用多个规则掩盖网址

时间:2014-07-14 16:38:24

标签: regex apache .htaccess mod-rewrite

我在根文件夹中有这个htaccess文件。

    Options +FollowSymLinks
    RewriteEngine On


    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d 

    #RewriteCond %{HTTP_HOST} ^localhost/squash_test/find_a_player
    #RewriteRule ^(.*) http://localhost/squash_test/home/find_a_player [P]

    RewriteRule ^(.*) index.php?route=$1 [L,QSA]

这一切都很好。 我想要的是,保持现有的功能,我想掩盖两个网址。

如果我访问

http://localhost/squash_test/find_a_player

然后它应该显示来自

的内容
http://localhost/squash_test/home/find_a_player

同样,我有另一个网址,需要这样的屏蔽。我试图在互联网上搜索,我确实得到了一些解决方案,但没有一个正确。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

您可以使用:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(squash_test)/(find_a_player)/?$ /$1/home/$2 [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)$ index.php?route=$1 [L,QSA]
相关问题