2012-02-26 57 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