问题
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