0

I have website on Phalcon and everything works fine (I have SSL) but now I would like to have an access to the forum (https://www.example.com/forum/) but I have a problem with the .htaccess configuration.

Phalcon have the specific config:

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_HOST} !^www.example.com [NC]
 RewriteRule ^(.*)$ http://www.example.com%{REQUEST_URI} [R=301,L]
 RewriteCond %{HTTPS} !=on
 RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
 RewriteRule ^$ public/ [L]
 RewriteRule (.*) public/1ドル [L]
</IfModule>

What is the correct configuration for home domain and /forum/ folder?

Shiva127
2,6951 gold badge29 silver badges29 bronze badges
asked Mar 29, 2017 at 8:44

2 Answers 2

1
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule ^ "http://www.example.com%{REQUEST_URI}" [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ "https://%{SERVER_NAME}%{REQUEST_URI}" [R,L]
RewriteCond %{REQUEST_URI} !^/forum/
RewriteRule ^.*$ public/0ドル [L]
answered Mar 29, 2017 at 8:57
Sign up to request clarification or add additional context in comments.

2 Comments

Great! You might want to accept Deadooshka's answer :)
Hey @Deadooshka, it's frowned upon to post code only answers. Can you add a small explanation of what you did/what's going on?
1

Phalcon's root .htaccess file redirects all traffic to /public folder. What you need to do is add one more condition to your final rewrite rule. Here is portion of my .htaccess file:

<IfModule mod_rewrite.c>
 RewriteEngine On
 # Force www
 RewriteCond %{HTTP_HOST} !^$
 RewriteCond %{HTTP_HOST} !^www\. [NC]
 RewriteCond %{HTTPS}s ^on(s)|
 RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
 # Remove trailing slash
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_URI} (.+)/$
 RewriteRule ^ %1 [R=301,L]
 # Forward to public/
 RewriteRule ^(forum)($|/) - [L]
 RewriteRule ^(.*)$ public/1ドル [L]
</IfModule>

This RewriteRule ^(forum)($|/) - [L] is the important condition you need to add before RewriteRule ^.*$ public/0ドル [L]

Also you can add as much as rules you want to allow multiple folders.

RewriteRule ^(forum)($|/) - [L]
RewriteRule ^(some-other-folder)($|/) - [L]
...
answered Mar 29, 2017 at 9:22

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.