"Christmas - the time to fix the computers of your loved ones" « Lord Wyrm

apache: umzug von subdirectory auf subdomain

wergor 10.10.2019 - 00:02 2353 4
Posts

wergor

connoisseur de mimi
Avatar
Registered: Jul 2005
Location: graz
Posts: 4019
ich will meine ampache (läuft auf apache) url von domain.com/ampache auf ampache.domain.com umziehen. ich habe die ampache.conf angepasst:
Code:
<VirtualHost *:80>
        ServerName ampache.domain.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/ampache

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =ampache.domain.com
RewriteRule ^ [url]https://%[/url]{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName ampache.domain.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/ampache

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
ServerName ampache.domain.com
    <IfModule mod_headers.c>
      Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
    </IfModule>
SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
</VirtualHost>
</IfModule>
ich habe aber offenbar noch ein problem mit meinen redirects, denn ampache.domain.com wird auf ampache.domain.com/ampache umgeleitet (und der server returned 404). ich kann zwar z.b. die login.php via ampache.domain.com/login.php aufrufen, die wird dann aber natürlich nicht richtig dargestellt und funktioniert auch nicht.

afaik muss ich die rewrites in den .htaccess files von ampache anpassen. was wären die richtigen rewrites in meinem fall?
/rest/.htaccess:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^(.+)\.view$ /rest/index.php?ssaction=$1 [PT,L,QSA]
    RewriteRule ^fake/(.+)$ /play/$1 [PT,L,QSA]
</IfModule>
/play/.htaccess:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^art/([^/]+)/([^/]+)/([0-9]+)/thumb([0-9]*)\.([a-z]+)$ /image.php?object_type=$2&object_id=$3&auth=$1&thumb=$4&name=art.jpg [L]
    RewriteRule ^([^/]+)/([^/]+)/([^/]+)/([^/]+)(/.*)?$ /play/$5?$1=$2&$3=$4 [N,QSA]
    RewriteRule ^([^/]+)/([^/]+)(/.*)?$ /play/$3?$1=$2 [N,QSA]
    RewriteRule ^(/[^/]+|[^/]+/|/?)$ /play/index.php [L,QSA]
</IfModule>
/channel/.htaccess:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-s
    RewriteRule ^([0-9]+)/(.*)$ /channel/index.php?channel=$1&target=$2 [PT,L,QSA]
</IfModule>
(es gibt noch ein paar andere, aber soweit ich gesehen habe stehen überall die gleichen RewriteCond und RewriteRule drin oder sachen die sich nicht auf urls beziehen)

wergor

connoisseur de mimi
Avatar
Registered: Jul 2005
Location: graz
Posts: 4019
Niemand hier der sich mit rewrites auskennt? Oder vielleicht liegt mein Problem ja wo anders?

kleinerChemiker

Here to stay
Avatar
Registered: Feb 2002
Location: Wien
Posts: 4248
Kann es sein, dass in deinen PHP Skripten auch Pfade und Domains in der Config gespeichert sind und die noch nicht geändert wurden?

Ich bin nicht der Apache Experte, kann da aber in den Regeln nichts falsches erkennen.

wergor

connoisseur de mimi
Avatar
Registered: Jul 2005
Location: graz
Posts: 4019
das wars! ich musste nur noch in der ampache config/ampache.cfg.php file die web_path variable auskommentieren. danke für den tipp! :)
Code:
; The public path to your ampache install
; Do not put a trailing / on this path
; For example if your site is located at [url]http://localhost[/url]
; than you do not need to enter anything for the web_path
; if it is located at [url]http://localhost/music[/url] you need to
; set web_path to /music
; DEFAULT: ""
;web_path = "/ampache"

mat

Administrator
Legends never die
Avatar
Registered: Aug 2003
Location: nö
Posts: 25373
Am besten du schaltest das Logging für Rewrites ein, dann kannst du sehr gut nachvollziehen, was hier passiert.
Kontakt | Unser Forum | Über overclockers.at | Impressum | Datenschutz