.htaccess htaccess重写为force index.php
我有以下格式的链接: 市民亦可于以下网址索取: 如何重定向没有index.php文件名的文件以使用url的index.php部分.htaccess htaccess重写为force index.php,.htaccess,url,mod-rewrite,.htaccess,Url,Mod Rewrite,我有以下格式的链接: 市民亦可于以下网址索取: 如何重定向没有index.php文件名的文件以使用url的index.php部分 我的htaccess文件中有其他重定向规则,它们工作正常,我只是不知道如何强制index.php部分并包括查询字符串。将以下规则放在站点根目录下的.htaccess文件中 RewriteEngine On RewriteBase / #only for the root directory RewriteCond %{REQUEST_URI} ^/$ #if the
我的htaccess文件中有其他重定向规则,它们工作正常,我只是不知道如何强制index.php部分并包括查询字符串。将以下规则放在站点根目录下的.htaccess文件中
RewriteEngine On
RewriteBase /
#only for the root directory
RewriteCond %{REQUEST_URI} ^/$
#if the uri is not already index.php
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteRule ^$ /index.php [R=301,L]
如果仍然存在与其他规则的冲突,可以通过在上面的重写规则之前添加followind条件,进一步将此规则限制为仅具有page=
querystring参数的请求
# to limit further to only the requests with a page= param
RewriteCond %{QUERY_STRING} ^([^&]+&)*page=.*$ [NC]
将以下规则放入站点根目录下的.htaccess文件中
RewriteEngine On
RewriteBase /
#only for the root directory
RewriteCond %{REQUEST_URI} ^/$
#if the uri is not already index.php
RewriteCond %{REQUEST_URI} !^/index.php [NC]
RewriteRule ^$ /index.php [R=301,L]
如果仍然存在与其他规则的冲突,可以通过在上面的重写规则之前添加followind条件,进一步将此规则限制为仅具有page=
querystring参数的请求
# to limit further to only the requests with a page= param
RewriteCond %{QUERY_STRING} ^([^&]+&)*page=.*$ [NC]
这不管用。它不会重定向我最初发布的链接,并且会断开一些不应该的链接。我通过添加另一个条件来限制此规则的范围。让我知道这是否有效。这不起作用。它不会重定向我最初发布的链接,并且会断开一些不应该的链接。我通过添加另一个条件来限制此规则的范围。让我知道这是否有效。