Skip to content

docs: add Apache config for baseURL with subfolder #7680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions user_guide_src/source/installation/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,86 @@ The above configuration assumes the project folder is located as follows:
│ └── public/ (DocumentRoot for myproject.local)
└── htdocs/

Restart Apache.

Testing
-------

With the above configuration, your webapp would be accessed with the URL **http://myproject.local/** in your browser.

Apache needs to be restarted whenever you change its configuration.

Hosting with Subfolder
======================

If you want a baseURL like **http://localhost/myproject/** with a subfolder,
there are three ways.

Making Symlink
--------------

Place your project folder as follows, where **htdocs** is the Apache document root::

├── myproject/ (project folder)
│ └── public/
└── htdocs/

Navigate to the **htdocs** folder and create a symbolic link as follows::

> cd htdocs/
> ln -s ../myproject/public/ myproject

Using Alias
-----------

Place your project folder as follows, where **htdocs** is the Apache document root::

├── myproject/ (project folder)
│ └── public/
└── htdocs/

Add the following in the main configuration file, e.g., **apache2/conf/httpd.conf**:

.. code-block:: apache

Alias /myproject /opt/lamp/apache2/myproject/public
<Directory "/opt/lamp/apache2/myproject/public">
AllowOverride All
Require all granted
</Directory>

Restart Apache.

Adding .htaccess
----------------

The last resort is to add **.htaccess** to the project root.

It is not recommended that you place the project folder in the document root.
However, if you have no other choice, like on a shared server, you can use this.

Place your project folder as follows, where **htdocs** is the Apache document root,
and create the **.htaccess** file::

└── htdocs/
└── myproject/ (project folder)
├── .htaccess
└── public/

And edit **.htaccess** as follows:

.. code-block:: apache

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

<FilesMatch "^\.">
Require all denied
Satisfy All
</FilesMatch>

Hosting with mod_userdir (Shared Hosts)
=======================================

Expand Down