.htaccess重定向无法正常工作?

时间:2015-08-13 13:06:22

标签: .htaccess

.htaccess文件无效... 我不知道为什么? 帮帮我这里是我的代码 .htaccess文件

   RewriteEngine on
RewriteBase /
RewriteCond  %{REQUEST_FILENAME} !-f
RewriteCond  %{REQUEST_FILENAME} !-d
Rewrite
Rule  ^(.*)$ index.php?name=$1 [QSA,L]

和php文件。

 if (isset($_GET['usernamess']) === true && empty($_GET['usernamess']) === false) {
    $usernamess = $_GET['usernamess'];
echo $usernamess;
}else {
header('index.php');
}

1 个答案:

答案 0 :(得分:1)

在Root / .htaccess文件中尝试此操作:

RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php\?name=([^\s]+) [NC] 
RewriteRule ^ /%1? [NC,R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?name=$1 [QSA,L,NC]

和name和usernamess应该是相同的