2014-01-11 135 views
-1

我想将index.php重定向到主要网址或/ index到主要网址。我正在使用Zend Framework。
我目前的.htaccessZend .htaccess重定向到主要网址

#Options +FollowSymLinks 
#Options -MultiViews 
RewriteEngine On 
Redirect 301 /index https://sim.ca/ 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.*$ – [NC,L] 
RewriteRule ^.*$ /index.php [NC,L] 

我想要做一些URL重写:如果有人类型https://sim.ca/index.phphttps://sim.ca/index然后它会被重定向到https://sim.ca

回答

0

你应该能够简化你的规则是:

#Options +FollowSymLinks 
#Options -MultiViews 
RewriteEngine On 
RewriteBase/

#Redirect /index and /index.php to/
RewriteRule ^index(\.php)?$/[R=301,L] 

#Any custom rules should be above here 
RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule^– [NC,L] 

#Rewrite all requests that reach this point to the router page 
RewriteRule^/index.php [NC,L] 
0

让你的规则是这样的:

选项+ FollowSymLinks -MultiViews

RewriteEngine On 
RewriteBase/

RewriteCond %{THE_REQUEST} /index(\.php)? [NC] 
RewriteRule ^index(\.php)?/?$ https://sim.ca/ [L,R=301,NC] 

RewriteCond %{REQUEST_FILENAME} -s [OR] 
RewriteCond %{REQUEST_FILENAME} -l [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule^– [L] 

RewriteRule^/index.php [L]