I want to rewrite test.com to test.com/context.
The browser returns redirection recursion error.
Anyone has a clue?
I put below in httpd-vhosts.conf.
<VirtualHost *:80>
ServerName test.com
JkMount /* mschoi
ErrorLog logs/mschoi-error_log
CustomLog logs/mschoi-acces_log common
RewriteEngine On
RewriteRule ^/(.*)$ /context/$1 [L,R]
</VirtualHost>
httpd.conf
Include conf/extra/httpd-vhosts.conf
This is a simple case of your rule matching
/contextagain when it rewrites. You can just use aRewriteCondto avoid it:If the files being accessed actually exist (rather than a rewrite pattern) you can test for and not rewrite any real existing files:
Edit after comment to explain:
Not only per-directory rules can cause recursion. In this case, it is the simple matter that
/(.*)matches anything and that gets appended unconditionally to/content. Since the[R]flag is present to redirect and each of these is a new request, it becomes a redirection chain of :Subsequent redirects always continue to match the leading
/contentas well as what follows with/(.*)and append to it.