将所有页面请求重定向到一个页面

时间:2009-10-21 09:09:13

标签: .htaccess mod-rewrite redirect

我需要将特定域上的所有页面请求(php,如果这很重要)重定向到该域上的特定页面(再次,php)。我正在寻找一个.htaccess,mod_rewrite解决方案,以便于实现。

2 个答案:

答案 0 :(得分:3)

尝试此规则:

RewriteCond $1 !=index.php
RewriteRule .+\.php$ index.php [L]

这会将所有URL路径以.php结尾的请求重定向到与.htaccess文件相同的目录中的 index.php

答案 1 :(得分:2)

这样的事情可能会起到作用:

RewriteEngine On

RewriteBase /

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

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