htaccess重写url的querystring规则



我刚刚对一个网站做了一个巨大的改造,改变了框架。因此,url的结构发生了变化。这不是一个大问题,除了一个url,这是使用很多。我需要将用户从旧地址重定向到新地址,但我不知道该怎么做。

  • 旧url: domain/?page/subpage/subsubpage.html?param =(参数)/
  • 新url: domain/controller/function/[parameter]/

我现在的重写规则是:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [L]
RewriteRule ^/?page/subpage/subsubpage.html?param=(.*)$ /controller/function/$1 [L]

但是它不起作用,没有发生重定向。

编辑:添加了整个htaccess文件!这目前给了我错误500("请求超过了10个内部重定向的限制,由于可能的配置错误。")
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Allow asset folders through
RewriteRule ^(fuel/modules/(.+)?/assets/(.+)) - [L]
RewriteRule ^(fuel/modules/(.+)?/tuki/(.+)) - [L]
RewriteRule ^(fuel/modules/(.+)?/wiki/(.+)) - [L]


# Protect application and system files from being viewed
RewriteRule ^(fuel/install/.+|fuel/crons/.+|fuel/data_backup/.+|fuel/codeigniter/.+|fuel/modules/.+|fuel/application/.+) - [F,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^/?page/subpage/subsubpage.html?param=(.*)$ /controller/function/$1 [L]

RewriteRule .* index.php/$0 [L]

# Prevents access to dot files (.git, .htaccess) - security.
RewriteCond %{SCRIPT_FILENAME} -d
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule "(^|/)." - [F]


</IfModule>
Options -Indexes

与您显示的样品/尝试,请尝试以下。请确保在测试url之前清除浏览器缓存。

Options +FollowSymLinks
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine ON
RewriteBase /
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Prevents access to dot files (.git, .htaccess) - security.
RewriteRule .(git|htaccess) - [F]
# Allow asset folders through
RewriteRule ^fuel/modules/(assets|tuki|wiki) - [L]
# Protect application and system files from being viewed
RewriteRule ^fuel/(install|crons|data_backup|codeigniter|modules|application)/.+ - [F,L]
##Any non existing directory OR files whose URI srarts from page rule.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?page/subpage/subsubpage.html?param=(.*)$ /controller/function/$1 [L]
####If any non existing directory OR file is requested then come here:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php/$0 [L]

###New rule added by me here.....
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
ReWriteCond %{QUERY_STRING} .*=([^/[]*)/?$
RewriteRule ^ controller/function/%1 [L]  
</IfModule>

最新更新