2012-03-06 65 views
1

当有人输入/ 5或其他东西时,我的.htaccess重定向,但是如果他们只键入域,我该如何使它不重定向?编辑htaccess,如果域中只有url,则不重定向

所以southeast.tv/5/e将重定向, 但southeast.tv只会继续担任southeast.tv

这里是我现在的代码:

RewriteEngine on 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]*)/?([^/]*)/?$ http://southeast.tv/index.php?v=$1&t=$2 

回答

0

添加RewriteCond否定请求到/只能用^[/]?$

RewriteEngine on 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 

# Only rewrite if the request is not for `/` The ? probably isn't needed 
Rewritecond %{REQUEST_URI} !^[/]?$ 
RewriteRule ^([^/]*)/?([^/]*)/?$ http://southeast.tv/index.php?v=$1&t=$2 [L,R=301] 
+0

'!^ $'就够了。只有非常古老的apache版本需要一个主要的斜杠。 – Gerben 2012-03-06 15:46:54

+0

由于某种原因,它仍然是重定向。除了现在,而不是一个空的$ 1它有:index.html.var – Samir 2012-03-06 16:05:05

+0

@Tyler添加'[L,R = 301]'... – 2012-03-06 16:07:30