Ante todo disculparme, porque aunque sé que hay muchas respuestas a mi pregunta, lo cierto, es que al no entender muy bien las respuestas, parece que no consigo hacerlo bien en mi página. He leido todo esto: Symfony Respuesta 1 Respuesta 2 Respuesta 3
Tengo 2 softwares en mi servidor, un portal (Zikula - Basado en Symfony 5) y un foro (SMF). Estoy actualizando la versión de Zikula a esta nueva versión en Symfony 5, que funciona bajo la carpeta "public". Como tantos otros, quiero ocultar de la URL este subdirectorio para que las URLs sean más amigables e iguales a las que tengo ahora sin actualizar. Entonces, cada software lo tengo bajo la carpeta /public_html del servidor. Zikula bajo la carpeta "portal" y el foro bajo "foro".
Actualmente, tengo un .htaccess en "/public_html" para redireccionar dominios.
RewriteEngine on
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName heroesofmightandmagic.es
Options All -Indexes
RewriteCond %{HTTP_HOST} ^heroesofmightandmagic.es$ [OR]
RewriteCond %{HTTP_HOST} ^www.heroesofmightandmagic.es$
RewriteRule ^/?$ "https\:\/\/www\.heroesofmightandmagic\.es\/portal\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^torredemarfil\.es$ [OR]
RewriteCond %{HTTP_HOST} ^www\.torredemarfil\.es$
RewriteRule ^/?$ "https\:\/\/www\.torredemarfil\.es\/foro\/" [R=301,L]
Y sé que tengo otro .htaccess bajo la carpeta de symfony "/public", que es el que viene por defecto entiendo.
# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex index.php
# By default, Apache does not evaluate symbolic links if you did not enable this
# feature in your server configuration. Uncomment the following line if you
# install assets as symlinks or if you experience problems related to symlinks
# when compiling LESS/Sass/CoffeScript assets.
Options FollowSymlinks
# Allow web access in /public folder
<IfModule !mod_authz_core.c>
# Apache 2.2
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
# Apache 2.4
Require all granted
</IfModule>
# Disabling MultiViews prevents unwanted negotiation, e.g. "/index" should not resolve
# to the front controller "/index.php" but be rewritten to "/index.php/index".
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
# Enable short urls if supported
<IfModule mod_rewrite.c>
# Turn the rewriting engine on
RewriteEngine On
# Determine the RewriteBase automatically and set it as environment variable.
# If you are using Apache aliases to do mass virtual hosting or installed the
# project in a subdirectory, the base path will be prepended to allow proper
# resolution of the index.php file and to redirect to the correct URI. It will
# work in environments without path prefix as well, providing a safe, one-size
# fits all solution. But as you do not need it in this case, you can comment
# the following 2 lines to eliminate the overhead.
RewriteCond %{REQUEST_URI}::$0 ^(/.+)/(.*)::\2$
RewriteRule .* - [E=BASE:%1]
# Sets the HTTP_AUTHORIZATION header removed by Apache
RewriteCond %{HTTP:Authorization} .+
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%0]
# Redirect to URI without front controller to prevent duplicate content
# (with and without `/index.php`). Only do this redirect on the initial
# rewrite by Apache and not on subsequent cycles. Otherwise we would get an
# endless redirect loop (request -> rewrite to front controller ->
# redirect -> request -> ...).
# So in case you get a "too many redirects" error or you always get redirected
# to the start page because your Apache does not expose the REDIRECT_STATUS
# environment variable, you have 2 choices:
# - disable this feature by commenting the following 2 lines or
# - use Apache >= 2.3.9 and replace all L flags by END flags and remove the
# following RewriteCond (best solution)
RewriteCond %{ENV:REDIRECT_STATUS} =""
RewriteRule ^index\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
# If the requested filename exists, simply serve it.
# We only want to let Apache serve files and not directories.
# Rewrite all other queries to the front controller.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ %{ENV:BASE}/index.php [L]
</IfModule>
<IfModule !mod_rewrite.c>
<IfModule mod_alias.c>
# When mod_rewrite is not available, we instruct a temporary redirect of
# the start page to the front controller explicitly so that the website
# and the generated links can still be used.
RedirectMatch 307 ^/$ /index.php/
# RedirectTemp cannot be used instead
</IfModule>
</IfModule>
Y con todo lo leido anteriormente, tengo varias dudas. No sé si las respuestas las tengo que poner en el .htaccess de "public_html" o bajo la de "/public" de symfony. No sé si tengo que desactivar(eliminar) uno de los 2 .htaccess al aplicar la solución o no. En fin, como véis, estoy bastante perdido. Si me pudiesen echar una mano.
Estoy haciendo el upgrade en un sitio de pruebas. Y de ahí lo que quiero es quitar ese "public".
Gracias.
RewriteRule ^zk2to3/(.*)$ /zk2to3/public/$1
pero luego tienes que tener en cuenta dos cosas: 1) No sabemos que contiene el .htaccess de public/, por lo tanto quizás haga cosas inesperadas cuando llegue la petición y 2) Los enlaces de las páginas que cuelguen de public/ no deben llevar el /public para que funcione bien (eso si el punto 1 no hace nada raro)RewriteEngine On
2)RewriteCond %{REQUEST_FILENAME} !-f
y 3)RewriteRule ^ index.php [L]
a ver si cuela/zk2to3/
? ¿en que carpeta está exactamente el segundo .htaccess? Es que es raro el mensaje de error que aparece, pues no es el típico de apache, sinó personalizado para Zikula y no acabo de entender porque aparece así (a menos que tengas archivos personalizados 404 en esas carpetas, pero a nivel de .htaccess no parece que llames a ninguno en concreto)