2015-03-02 64 views
1

我有这个网站具有以下结构我怎样才能重定向仅主文件

site 
    |-- .htaccess 
    |-- index.php 
    |-- other files and directories 

index.php文件用于每重定向。我如何才能使用修改.htaccess只有当有人想要访问mydomain.com而不是当有人使用mydomain.com/otherlinkmydomain.com/index.php?stuff时重定向到mydomain.com/desiredLink

当前的.htaccess内容如下:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php|resources|assets|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

回答

1

您可以使用:

RewriteEngine on 
RewriteBase/

# redirect root URL 
RewriteRule ^/?$ /desiredLink [L,R] 

# other than root URL 
RewriteCond $1 !^(index\.php|resources|assets|robots\.txt) [NC] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.+)$ index.php/$1 [L] 
+1

这似乎是工作的罚款。谢谢。 – codiac 2015-03-02 12:23:27

+0

不客气,很高兴它解决了。 – anubhava 2015-03-02 12:25:32