.htaccess 主页+;从GET参数重定向值
我需要在我的网站上打开.htaccess 主页+;从GET参数重定向值,.htaccess,.htaccess,我需要在我的网站上打开file.php作为索引。主页上的将打开file.php,无需重定向到www.website.com/file.php 第二个重写规则是将www.website.com/?id={id}重定向到www.website.com/{id} RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ file.php?id=
file.php
作为索引。主页上的将打开file.php
,无需重定向到www.website.com/file.php
第二个重写规则是将www.website.com/?id={id}
重定向到www.website.com/{id}
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ file.php?id=$1
RewriteRule ^$ /file.php
RewriteCond %{QUERY_STRING} ^(.*&)?id=([^&]*)(&.*)?$
RewriteRule ^ %{REQUEST_URI}?%1%2%3
帮助我使用htaccess代码?您可以使用如下规则:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+\?id=([^\s&]+)\s [NC]
RewriteRule ^ /%1? [R=301,L,NE]
RewriteRule ^$ /file.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ file.php?id=$1 [L,QSA]
重写规则^page/%1?[R=301,L,NE]
-->重写规则^/%1?[R=301,L,NE]
…但这正是我需要的是,很抱歉,/page
是一个输入错误,因为我在本地apache上测试它。没关系,我立即知道“问题”在哪里-只是更正:)