我正在尝试将domain.com/players/重定向到domain.com/players/index.php?p=profile&player=,但没有成功。我昨天问了一些简单的东西,然后尝试了
RewriteRule ^(.*)$ domain.com/players/index.php?p=profile&player=$1 [L]
但是它只是没有重定向我?目前,我的.htaccess文件如下所示:
Options -Indexes +FollowSymLinks
RewriteEngine On
RewriteBase /players/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ domain.com/players/index.php?p=profile&player=$1 [L]
我也有“ RewriteCond%{REQUEST_FILENAME}!-f”,但可以了解它的作用。
这有点奏效,但是仍然没有问题。问题之一是我无法访问domain.com/players。它将我重定向到domain.com/players/index.php?p=profile&player=index.php
另一件事是,我的网址栏中仍将包含domain.com/players/。是否可以这样显示网址domain.com/players/index.php?p=profile&player=的内容,但在网址栏中显示domain.com/players/?我认为其他用户看起来很丑。
对不起,我真的是.htaccess的初学者,但在发布此文章之前,我已尝试进行研究。
尝试一下
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} example.com$ [NC]
RewriteCond %{HTTP_HOST} !folder1
RewriteRule ^(.*)$ http://example.com/folder1/$1 [R=301,L]