2
如果blah.com/hello/index.php
不存在,是否有可能(使用.htaccess大概?)自动将blah.com/hello
重定向到blah.com/hello.php
?如果索引不存在,重定向到php页面
但是,如果有index.php
,我仍然想显示没有重定向。
如果blah.com/hello/index.php
不存在,是否有可能(使用.htaccess大概?)自动将blah.com/hello
重定向到blah.com/hello.php
?如果索引不存在,重定向到php页面
但是,如果有index.php
,我仍然想显示没有重定向。
尝试:
RewriteEngine on
#if /foo/index.php is not a file
RewriteCond %{REQUEST_FILENAME}\.index.php !-f
#then redirect /foo to /foo.php
RewriteRule ^([^./]+)/?$ /$1.php [NC,L,R]
谢谢!这似乎工作得很好:)是否有任何限制/这种方法的警告,我应该知道? –