问题
what I have so far is:
<VirtualHost 111.111.111.111:80>
ServerName ex.me
ServerAlias www.ex.me
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/(.*)$ http://exemple.com/foo/$1 [R=301,L]
</VirtualHost>
what I need is if (.*) is empty, it rewrites to http://exemple.com and if it has something, it redirects to http://exemple.com/foo/$1 -- I don't know how to do the if empty rule. right now. Right now it redirects to http://exemple.com/foo/ no matter if there is something captured or not.
Thanks for your help
回答1:
RewriteRule ^/$ http://exemple.com/ [R=301,L]
RewriteRule ^/(.+)$ http://exemple.com/foo/$1 [R=301,L]
来源:https://stackoverflow.com/questions/5466456/apache-rewrite-rule-different-if-capture-is-empty