0

I have ampache music server installed under example.com/ampache/public.

What should I write in example.com/.htaccess file to change the appearance of

example.com/ampache/public 

into

example.com/music 

In other words I need to replace middle part of URL /ampache/public/* with /music/*

2
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Oct 25, 2022 at 11:10
  • 1
    I am not sure if you need any. What url works from a remote browser now? Oct 25, 2022 at 18:42

1 Answer 1

1

It is potentially harmful to have people make assumptions when answering questions. I'm going on the assumption this is a self-host, not for distribution setup.

Normally a structure such as you are showing could reflex a resource directory. I looked at the Github of Ampache and there is an index.php in the directory under public ...

<!DOCTYPE html>
<html lang="en-US">
    <head>
        <!-- Propelled by Ampache | ampache.org -->
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Ampache -- Debug Page</title>
        <link rel='shortcut icon' href='./public/favicon.ico' />
        <link href="./public/lib/components/bootstrap/css/bootstrap.min.css" rel="stylesheet">
        <link href="./public/lib/components/bootstrap/css/bootstrap-theme.min.css" rel="stylesheet">
        <link rel="stylesheet" href="./public/templates/install.css" type="text/css" media="screen" />
    </head>
    <body>
        <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
            <div class="container" style="height: 70px;">
                <a class="navbar-brand" href="#">
                    <img src="./public/themes/reborn/images/ampache-dark.png" title="Ampache" alt="Ampache">
                    Ampache :: For the Love of Music                </a>
            </div>
        </div>
        <div id="guts" class="container" role="main">
            <div class="jumbotron" style="margin-top: 70px">
                <h1>Warning</h1>
                <p>The root Ampache folder has changed to <a href="./public" target="_blank">./public</a></p>
            </div>
            <div class="alert alert-danger">
                <p>You must update your DocumentRoot to the new path.</p>
                <p><a href="https://github.com/ampache/ampache/wiki/Ampache-Next-Changes" target="_blank">Please check the Ampache wiki for more information</a></p>
            </div>
        </div>
    </body>
</html>

They want you to change the document root but are not explaining why or how? Generally that would be done with-in the .conf for the server configuration.

But, you can use .htaccess to change the document root by not using the redirect flag

Normally you would use this var/www/html/.htaccess to change your document root.

RewriteEngine on
RewriteCond %{REQUEST_URI} !ampache/public/
RewriteRule (.*) /ampache/public/$1 [L]

resulting in example.com being the Ampache public page.

Note you may need the NE (no escape the string) flag for Ampache

RewriteRule (.*) /ampache/public/$1 [L, NE]

You are asking for example.com/music/ that can be done but be advised it is not what they are asking you to do and they may have their reasons! It will also not prevent browsing in the /ampache/ directory, which could be an issue!

RewriteEngine on
RewriteCond %{REQUEST_URI} /music/
RewriteRule (.*) /ampache/public/$1 [L]
# or 
# RewriteRule (.*) /ampache/public/$1 [L, NE]

Now when example.com/music/ is requested apache will get the information from /ampache/public/ but a request for /ampache will still operate. or a request for whatever else you have on the host.

Note

may need to enable rewrite on a self host.

sudo a2enmod rewrite

and may need to add the directory tag after the </VirtualHost> in your /etc/apache2/sites-enabled/000-default.conf to allow .htaccess

<Directory /var/www/html>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.