URL Rewrite and redirect

一个人想着一个人 提交于 2019-12-24 20:38:30

问题


I am having a small issue, I want to place rewrite url and redirect rule both. For example, I want to show content of abc.php when someone open abc.html and this can be done with url rewriting:

RewriteEngine On
RewriteRule    ^abc\.html$    abc.php [NC,L]   

But what if some one opens abc.php directly in browser, I want to send them on abc.html and when I place 301 redirect it doesn't work as it generates loop.

How I can do this?


回答1:


You can use:

RewriteEngine On

RewriteCond %{THE_REQUEST} /abc\.php[\s?] [NC]
RewriteRule ^ /abc.html [R=301,L]

RewriteRule ^abc\.html$ abc.php [NC,L]  


来源:https://stackoverflow.com/questions/35794507/url-rewrite-and-redirect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!