URL Rewrite and redirect

2019-09-14 11:40发布

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条回答
手持菜刀,她持情操
2楼-- · 2019-09-14 11:49

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]  
查看更多
登录 后发表回答