0
我在尝试将mod_rewrite集成到我现有的页面中完全失败。目前,我从头开始建立一个新的网站,在那里我有一些干净的网址,如:如何使用参数重定向url?
http://www.example.nl/nl/example
旧网站,运行CMS变得简单,具有一定的不改写的URL,将需要重定向到新的页面。这些网址是这样的:像的
http://www.example.nl/index.php?page=cake-and-pie&hl=nl_NL
但较短的版本:
http://www.example.nl/index.php?page=cake-and-pie
也行。
我花了一段时间才弄清楚带参数的网址不能简单地用“重定向301”重定向,就像我正常做的那样。所以我尝试了一些在线的mod_rewrite生成器,如this和this,但这些规则输出的规则只会导致404错误(重定向根本不起作用)。
我的.htaccess文件目前看起来是这样的:
RewriteEngine On
RewriteBase/
# remove .php;
RewriteCond %{THE_REQUEST} ^GET\ (.*)\.php\ HTTP
RewriteRule (.*)\.php$ $1 [R=301]
# remove index
RewriteRule (.*)/index$ $1/ [R=301]
# remove slash if not directory
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /$
RewriteRule (.*)/ $1 [R=301]
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
旧的页面会抓住存在。 我如何将旧页面重定向到新页面?
谢谢。
编辑
RewriteCond %{QUERY_STRING} =page=pie
RewriteRule ^index\.php$ /nl/? [L,R=301]
RewriteCond %{QUERY_STRING} =page=pie&hl=nl_NL
RewriteRule ^index\.php$ /nl/? [L,R=301]
似乎这样的伎俩。这当然是每个网址的手册,但我只有几个。
不知何故,这似乎打破...该网页没有重定向。 – Lg102 2011-06-14 15:26:50