Skip to main content
added 52 characters in body
Source Link
anubhava
  • 783.4k
  • 67
  • 592
  • 661

Here is a scenario of what I am trying to do.

Folder A has folders B and C. Folder B has D, E and index.html. Folder C has index.html

I declared folder B as my DocumentRoot. Declared an Alias for Folder C to point it to /A/C. I want apache to serve index.html in B for any requests coming in to B (/B/D or /B/E or /B/** should return /B/index.html)

Here is the sample virtual host config

<VirtualHost *:8080> ... DocumentRoot "/usr/local/var/www/A/B" Alias "/C" "/usr/local/var/www/A/C" <Directory "/usr/local/var/www/A"> ....

RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} !200 RewriteRule ^/B/.+ /B/ [PT] ....

<VirtualHost *:8080>
...
DocumentRoot "/usr/local/var/www/A/B" 
Alias "/C" "/usr/local/var/www/A/C" 
<Directory "/usr/local/var/www/A"> 
....
</Directory> 

RewriteEngine On 
RewriteCond %{ENV:REDIRECT_STATUS} !200 
RewriteRule ^/B/.+ /B/ [PT] 
....
</VirtualHost>

With this configuration, I am running in to redirect loop.

Here is a scenario of what I am trying to do.

Folder A has folders B and C. Folder B has D, E and index.html. Folder C has index.html

I declared folder B as my DocumentRoot. Declared an Alias for Folder C to point it to /A/C. I want apache to serve index.html in B for any requests coming in to B (/B/D or /B/E or /B/** should return /B/index.html)

Here is the sample virtual host config

<VirtualHost *:8080> ... DocumentRoot "/usr/local/var/www/A/B" Alias "/C" "/usr/local/var/www/A/C" <Directory "/usr/local/var/www/A"> ....

RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} !200 RewriteRule ^/B/.+ /B/ [PT] ....

With this configuration, I am running in to redirect loop.

Here is a scenario of what I am trying to do.

Folder A has folders B and C. Folder B has D, E and index.html. Folder C has index.html

I declared folder B as my DocumentRoot. Declared an Alias for Folder C to point it to /A/C. I want apache to serve index.html in B for any requests coming in to B (/B/D or /B/E or /B/** should return /B/index.html)

Here is the sample virtual host config

<VirtualHost *:8080>
...
DocumentRoot "/usr/local/var/www/A/B" 
Alias "/C" "/usr/local/var/www/A/C" 
<Directory "/usr/local/var/www/A"> 
....
</Directory> 

RewriteEngine On 
RewriteCond %{ENV:REDIRECT_STATUS} !200 
RewriteRule ^/B/.+ /B/ [PT] 
....
</VirtualHost>

With this configuration, I am running in to redirect loop.

added 260 characters in body
Source Link
vijay
  • 33
  • 3

I need apache RewriteRule for the followingHere is a scenario of what I am trying to do.

  1. /test/ to /test/
  2. /test/a to /test/
  3. /test/b to /test/
  4. /test/c/1 to /test/

The below RewriteRule worksFolder A has folders B and C. Folder B has D, E and index.html. Folder C has index.html

RewriteRule ^/test/[abc].+$ /test/ [NC,PT]

What would be the rewrite rule that would say, if there are one or more characters after /test/I declared folder B as my DocumentRoot. Declared an Alias for Folder C to point it must be redirected to /test//A/C. I want apache to serve index.html in B for any requests coming in to B (/B/D or /B/E or /B/** should return /B/index.html)

I triedHere is the sample virtual host config

^/test/.+$ /test/ [NC,PT]

<VirtualHost *:8080> ... DocumentRoot "/usr/local/var/www/A/B" Alias "/C" "/usr/local/var/www/A/C" <Directory "/usr/local/var/www/A"> ....

butRewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} !200 RewriteRule ^/B/.+ /B/ [PT] ....

With this did not matchconfiguration, I am running in any of the 4 cases and redirects to 404redirect loop.

I need apache RewriteRule for the following scenario

  1. /test/ to /test/
  2. /test/a to /test/
  3. /test/b to /test/
  4. /test/c/1 to /test/

The below RewriteRule works

RewriteRule ^/test/[abc].+$ /test/ [NC,PT]

What would be the rewrite rule that would say, if there are one or more characters after /test/ it must be redirected to /test/.

I tried

^/test/.+$ /test/ [NC,PT]

but this did not match in any of the 4 cases and redirects to 404.

Here is a scenario of what I am trying to do.

Folder A has folders B and C. Folder B has D, E and index.html. Folder C has index.html

I declared folder B as my DocumentRoot. Declared an Alias for Folder C to point it to /A/C. I want apache to serve index.html in B for any requests coming in to B (/B/D or /B/E or /B/** should return /B/index.html)

Here is the sample virtual host config

<VirtualHost *:8080> ... DocumentRoot "/usr/local/var/www/A/B" Alias "/C" "/usr/local/var/www/A/C" <Directory "/usr/local/var/www/A"> ....

RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} !200 RewriteRule ^/B/.+ /B/ [PT] ....

With this configuration, I am running in to redirect loop.

added 6 characters in body
Source Link
anubhava
  • 783.4k
  • 67
  • 592
  • 661

I need apache RewriteRule for the following scenario

  1. /test/ to /test/
  2. /test/a to /test/
  3. /test/b to /test/
  4. /test/c/1 to /test/

The below RewriteRule works

RewriteRule ^/test/[abc].+$ /test/ [NC,PT]

RewriteRule ^/test/[abc].+$ /test/ [NC,PT]

What would be the rewrite rule that would say, if there are one or more characters after "/test/"/test/ it must be redirected to "/test/"/test/.

I tried ^/test/.+$ /test/ [NC,PT],

^/test/.+$ /test/ [NC,PT]

but this did not match in any of the 4 cases and redirects to 404.

I need apache RewriteRule for the following scenario

  1. /test/ to /test/
  2. /test/a to /test/
  3. /test/b to /test/
  4. /test/c/1 to /test/

The below RewriteRule works

RewriteRule ^/test/[abc].+$ /test/ [NC,PT]

What would be the rewrite rule that would say, if there are one or more characters after "/test/" it must be redirected to "/test/".

I tried ^/test/.+$ /test/ [NC,PT], but this did not match in any of the 4 cases and redirects to 404.

I need apache RewriteRule for the following scenario

  1. /test/ to /test/
  2. /test/a to /test/
  3. /test/b to /test/
  4. /test/c/1 to /test/

The below RewriteRule works

RewriteRule ^/test/[abc].+$ /test/ [NC,PT]

What would be the rewrite rule that would say, if there are one or more characters after /test/ it must be redirected to /test/.

I tried

^/test/.+$ /test/ [NC,PT]

but this did not match in any of the 4 cases and redirects to 404.

Source Link
vijay
  • 33
  • 3
Loading