Zend .htaccess重定向到主URL

时间:2014-01-11 06:33:46

标签: .htaccess

我想将index.php重定向到主url,或者将/ index重定向到主url。我正在使用Zend Framework 我现在的.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]

我想进行一些网址重写:如果有人输入https://sim.ca/index.phphttps://sim.ca/index,则会将其重定向到https://sim.ca

2 个答案:

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

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