2015-11-04 74 views
1

我想要做的是将请求http://example.com/tel.php重定向到http://example.com/default/index/tel而不显示任何重定向给用户。我htaccess的这样做:用Apache重写内部URL

RewriteEngine On 

RewriteRule ^tel\.php$ /default/index/tel [NC,L] 


RewriteCond %{HTTP_HOST} !^www\. 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 

然而重定向显示了其中我试图避免用户(HTTP/1.1 301永久移动)。

如何解决这个问题?

+0

[看这个答案](http://stackoverflow.com/questions/7042234/301-redirect-with-custom-message) –

回答

1

更改你的规则的顺序和选择添加结尾斜杠如果

RewriteEngine On 

RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule^http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L] 

RewriteRule ^tel\.php$ /default/index/tel [NC,L] 
# make it as this if /default/index/tel/ is a real directory 
# RewriteRule ^tel\.php$ /default/index/tel/ [NC,L] 

确保清除浏览器缓存后对其进行测试。

+1

感谢您的帮助! – Steve