2012-02-26 54 views
1

从我的网址中删除“的index.php”定向到着陆页:使用的.htaccess我目前在我的.htaccess使用该

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule (.*) index.php [L] 

但我也想重定向网页(即example.com)添加到临时着陆页。所以example.com应该被定向到landing.html,但是我的应用程序的任何页面(即那些运行index.php的页面)都不受影响。我想:

RewriteRule/landing.html [L,R=302] 

RewriteRule !^index\.php$ landing.html [L,R=302] 

但它弄乱出于某种原因,CSS和相对路径。任何人都可以帮忙吗?

在我的httpd.conf DocumentRoot的是/var/www/html/example.com/current和该目录(“/电流”)被设置为AllowOverride All而/var/www/html/example.com设置为AllowOverride None

+0

@UlrichPalha [请不要修改标题,以解决加(http://meta.stackexchange.com/questions/116101/is-it-ok-to-add-solved-to-the-冠军的,别人 - 别人的-问题);它增加了噪音,并且已经存在一个标记为解决问题的机制。 – AakashM 2012-02-26 16:08:39

回答

4

找到了解决办法:

RedirectMatch 301 ^/$ /landing.html 
+6

+1自己解决。虽然请注意,'RedirectMatch'是来自'mod_alias'的指令,而不是'mod_rewrite'。 'mod_rewrite'是这样做的:'RewriteRule ^(?:$ | index \ .php)/landing.html [R,L]' – ThinkingMonkey 2012-02-26 16:12:14