[英]Remove .PHP and redirect through htaccess
Is that possible to hide the .PHP extension and redirect the URL at same time. 是否可以隐藏.PHP扩展名并同时重定向URL。
example : http://example.com/test need to redirect to http://someothersite.com 示例: http : //example.com/test需要重定向到http://someothersite.com
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^(.*)/test http://someothersite.com
But its not working. 但它不起作用。
Any idea ? 任何想法 ?
Thanks 谢谢
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^test http://someothersite.com [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
The code above is not tested, but it should give you an idea about it. 上面的代码没有经过测试,但它应该让你对它有所了解。 Use
L
flag after each set of rules, as it stops processing of the rest of the rules. 在每组规则之后使用
L
标志 ,因为它停止处理其余规则。
You need just this: 你需要这个:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ $1.php [R=301,L]
For cross domain rewriting: 对于跨域重写:
RewriteRule ^test http://someothersite.com [R=301,L]
Allways use L = 301 for permanent redirectings. 总是使用L = 301进行永久重定向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.