.htaccess URL重写不起作用(尝试使用它发送GET数据)


.htaccess URL Rewrite not working (trying to send GET data with it)

我正在尝试重写一个url,它看起来像http://example.com/View/(random_text)将用户带到http://example.com/View/site.php?site=(随机文本)

这就是我目前所讨论的:

Options -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^View/(.+)$ View/site.php?site=$1 [NC]

感谢您的帮助。

试试这个:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/View/(.+)$ /View/site.php?site=$2 [L,R=301]

如果"View"目录在Web服务器的根目录中,那么只添加一个正斜杠,如上所述。否则,将路径添加到视图目录,如下所示:

RewriteRule ^(.*)/View/(.+)$ /path_to_view_directory/View/site.php?site=$2 [L,R=301]