.htaccess: Transparently adding a name to the request
-
12-09-2019 - |
Question
I've read this tutorial about how to modify your .htaccess in order to server many web2py applications but it doesn't seem to work. Here is my .htaccess
RewriteEngine On
RewriteRule ^dispatch\.fcgi/ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
RewriteCond %{HTTP_HOST} =www.moublemouble.com [NC, OR]
RewriteCond %{HTTP_HOST} =moublemouble.com [NC]
RewriteRule ^/(.*) /moublemouble/$1 [PT,L]
All I get is a 500 Internal Error and .htaccess is not my strong point. Any clues?
Solution
It’s either the illegal space in [NC, OR]
or you are getting a recursion loop since the substitution /moublemouble/…
is also matched by the pattern ^/(.*)
. So try this:
RewriteCond %{HTTP_HOST} =www.moublemouble.com [NC,OR]
RewriteCond %{HTTP_HOST} =moublemouble.com [NC]
RewriteCond $1 !^moublemouble/
RewriteRule ^/(.*) /moublemouble/$1 [PT,L]
Or more compact:
RewriteCond %{HTTP_HOST} ^(www\.)?moublemouble\.com$ [NC]
RewriteRule !^/moublemouble/ /moublemouble%{REQUEST_URI} [PT,L]
OTHER TIPS
It might be your RewriteCond causing the problem.
I haven't tried it, but you could try...
RewriteCond %{HTTP_HOST} ^www.moublemouble.com [NC, OR]
RewriteCond %{HTTP_HOST} ^moublemouble.com [NC]
RewriteRule ^/(.*) /moublemouble/$1 [L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow