php - Laravel 4 htaccess redirect loop -


i have laravel 4 application , have subfolder applications. laravel 4 app in root folder , there .htaccess file there following content:

options -multiviews rewriteengine on rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]  rewritecond %{request_filename} !-f rewriterule ^ index.php [l] 

now, if go www.mysite.com/subfolder-app redirect loop error. error subfolder on server

you should able change rewriterule include sub-folder:

options -multiviews rewriteengine on rewritecond %{http_host} !^www\. rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]  rewritecond %{request_filename} !-f rewriterule ^ /subfolder-app/index.php [l] 

note, however, won't "dyamically" change environment. if localhost running laravel in webroot instead of sub-folder, making change htaccess file make no longer work in localhost dev environment.

one solution not use .htaccess file, rather include rewrite rule in virtual host configuration file domain. ability depend on hosting.

that solution has benefit of removing server-configuration (rather application configuration) out of our application code repository

edit

here's final resolution op used, it's not suggested:

options -multiviews   rewriteengine on   # rewrite "www" version rewritecond %{http_host} !^www\.  rewriterule ^(.*)$ http://www.%{http_host}/$1 [r=301,l]   # add -d check ensure rewrite if url  # not existing directory rewritecond %{request_filename} !-f  rewritecond %{request_filename} !-d  rewriterule ^ index.php [l] 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -