@@ -171,13 +171,86 @@ e.g., **apache2/conf/extra/httpd-vhost.conf**:
171
171
If your project folder is not a subfolder of the Apache document root, then your
172
172
``<VirtualHost> `` element may need a nested ``<Directory> `` element to grant the web server access to the files.
173
173
174
+ Restart Apache.
175
+
174
176
Testing
175
177
-------
176
178
177
179
With the above configuration, your webapp would be accessed with the URL **http://myproject.local/ ** in your browser.
178
180
179
181
Apache needs to be restarted whenever you change its configuration.
180
182
183
+ Hosting with Subfolder
184
+ ======================
185
+
186
+ If you want a baseURL like **http://localhost/myproject/ ** with a subfolder,
187
+ there are three ways.
188
+
189
+ Making Symlink
190
+ --------------
191
+
192
+ Place your project folder as follows, where **htdocs ** is the Apache document root::
193
+
194
+ ├── myproject (project folder)
195
+ │ └── public
196
+ └── htdocs
197
+
198
+ Navigate to the **htdocs ** folder and create a symbolic link as follows::
199
+
200
+ > cd htdocs/
201
+ > ln -s ../myproject/public/ myproject
202
+
203
+ Using Alias
204
+ -----------
205
+
206
+ Place your project folder as follows, where **htdocs ** is the Apache document root::
207
+
208
+ ├── myproject (project folder)
209
+ │ └── public
210
+ └── htdocs
211
+
212
+ Add the following in the main configuration file, e.g., **apache2/conf/httpd.conf **:
213
+
214
+ .. code-block :: apache
215
+
216
+ Alias /myproject /opt/lamp/apache2/myproject/public
217
+ <Directory "/opt/lamp/apache2/myproject/public">
218
+ AllowOverride All
219
+ Require all granted
220
+ </Directory>
221
+
222
+ Restart Apache.
223
+
224
+ Adding .htaccess
225
+ ----------------
226
+
227
+ The last resort is to add **.htaccess ** to the project root.
228
+
229
+ It is not recommended that you place the project folder in the document root.
230
+ However, if you have no other choice, like on a shared server, you can use this.
231
+
232
+ Place your project folder as follows, where **htdocs ** is the Apache document root,
233
+ and create the **.htaccess ** file::
234
+
235
+ └── htdocs
236
+ └── ci436 (project folder)
237
+ └── .htaccess
238
+ └── public
239
+
240
+ And edit **.htaccess ** as follows:
241
+
242
+ .. code-block :: apache
243
+
244
+ <IfModule mod_rewrite.c>
245
+ RewriteEngine On
246
+ RewriteRule ^(.*)$ public/$1 [L]
247
+ </IfModule>
248
+
249
+ <FilesMatch "^\.">
250
+ Require all denied
251
+ Satisfy All
252
+ </FilesMatch>
253
+
181
254
Hosting with mod_userdir (Shared Hosts)
182
255
=======================================
183
256
0 commit comments