如果只有域在URL中,则编辑htaccess以不重定向

时间:2012-03-06 14:04:18

标签: .htaccess redirect

当有人输入/ 5或其他内容时,我有.htaccess重定向,但如果他们只输入域名,我该如何使其不重定向?

所以southeast.tv/5/e将重定向, 但是东南.tv只会留在东南.tv

现在是我的代码:

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

1 个答案:

答案 0 :(得分: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]
相关问题