Jump to content

[SOLVED] Admin URL redirect to root URL


sebr
 Share

Recommended Posts

Hi

I just publish a new website in production environnement and I cannot anymore access to the admin URL... Automatically redirect to root URL.

Example : www.test.com/gestion ==> www.test.com

I disabled all HTTPS and www redirection in .htaccess but nothing changed.

Is someone can help me ?

Thanks in advance

......................................

This is my htaccess content :

#################################################################################################
# START PROCESSWIRE HTACCESS DIRECTIVES
# @version 3.0
# @indexVersion 300
#################################################################################################

# -----------------------------------------------------------------------------------------------
# 1. Don't show directory indexes, but do follow symbolic links 
# 500 NOTE: Some cloud hosting companies don't allow +FollowSymLinks. 
# Uncomment +SymLinksifOwnerMatch and comment +FollowSymLinks if you have 500 errors. 
# If that doesn't resolve the error, then set it back to +FollowSymLinks. 
# -----------------------------------------------------------------------------------------------

Options -Indexes
Options +FollowSymLinks
# Options +SymLinksifOwnerMatch

# -----------------------------------------------------------------------------------------------
# 2. Let ProcessWire handle 404s
# -----------------------------------------------------------------------------------------------

ErrorDocument 404 /index.php

# -----------------------------------------------------------------------------------------------
# 3. Handle request for missing favicon.ico/robots.txt files (no ending quote for Apache 1.3)
# -----------------------------------------------------------------------------------------------

<Files favicon.ico>
  ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>

<Files robots.txt>
  ErrorDocument 404 "The requested file robots.txt was not found.
</Files>

# -----------------------------------------------------------------------------------------------
# 4. Protect from XSS with Apache headers
# -----------------------------------------------------------------------------------------------

<IfModule mod_headers.c>
  # prevent site from being loaded in an iframe on another site
  # you will need to remove this one if you want to allow external iframes
  Header always append X-Frame-Options SAMEORIGIN 

  # to prevent cross site scripting (IE8+ proprietary)
  Header set X-XSS-Protection "1; mode=block"

  # prevent mime-based attacks via content sniffing (IE+Chrome)
  # Header set X-Content-Type-Options "nosniff" 
</IfModule>

# -----------------------------------------------------------------------------------------------
# 5. Protect ProcessWire system files 
# -----------------------------------------------------------------------------------------------

<FilesMatch "\.(inc|info|info\.json|module|sh|sql)$|^\..*$|composer\.(json|lock)$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order allow,deny
  </IfModule>
</FilesMatch>

# -----------------------------------------------------------------------------------------------
# 6. Override a few PHP settings that can't be changed at runtime (not required)
# 500 NOTE: Try commenting out this entire section below if getting Apache 500 errors.
# -----------------------------------------------------------------------------------------------

<IfModule mod_php5.c>
  php_flag magic_quotes_gpc		off
  php_flag magic_quotes_sybase		off
  php_flag register_globals		off
</IfModule>

# -----------------------------------------------------------------------------------------------
# 7. Set default directory index files
# -----------------------------------------------------------------------------------------------

DirectoryIndex index.php index.html index.htm

# -----------------------------------------------------------------------------------------------
# 8. ProcessWire requires mod_rewrite
# -----------------------------------------------------------------------------------------------

<IfModule mod_rewrite.c>

  RewriteEngine On
  AddDefaultCharset UTF-8

  # -----------------------------------------------------------------------------------------------
  # 9. If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below.
  # -----------------------------------------------------------------------------------------------
  # RewriteCond %{HTTPS} off
  # RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  
  # If using an AWS load balancer, use these two lines below instead of those above:
  # RewriteCond %{HTTP:X-Forwarded-Proto} =http 
  # RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  # -----------------------------------------------------------------------------------------------
  # 10. Set an environment variable so the installer can detect that mod_rewrite is active.
  # Note that some web hosts don't support this. If you get a 500 error, you might try 
  # commenting out this SetEnv line below. 
  # -----------------------------------------------------------------------------------------------

  <IfModule mod_env.c>
    SetEnv HTTP_MOD_REWRITE On
  </IfModule>

  # -----------------------------------------------------------------------------------------------
  # 11. OPTIONAL: Set a rewrite base if rewrites aren't working properly on your server.
  # And if your site directory starts with a "~" you will most likely have to use this.
  # -----------------------------------------------------------------------------------------------

  # RewriteBase /
  # RewriteBase /pw/
  # RewriteBase /~user/

  # -----------------------------------------------------------------------------------------------
  # 12. Access Restrictions: Keep web users out of dirs that begin with a period,
  # but let services like Lets Encrypt use the webroot authentication method.
  # -----------------------------------------------------------------------------------------------

  RewriteRule "(^|/)\.(?!well-known)" - [F]

  # -----------------------------------------------------------------------------------------------
  # 13. OPTIONAL: Redirect users to the 'www.' version of the site (uncomment to enable).
  # For example: http://processwire.com/ would be redirected to http://www.processwire.com/
  # -----------------------------------------------------------------------------------------------
  
  # RewriteCond %{HTTP_HOST} !^www\. [NC]
  # RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

  # ----------------------------------------------------------------------------------------------- 
  # 14. OPTIONAL: Send URLs with non-ASCII name-format characters to 404 page (optimization)
  # ----------------------------------------------------------------------------------------------- 

  # RewriteCond %{REQUEST_URI} "[^-_.a-zA-Z0-9/~]"
  # RewriteCond %{REQUEST_FILENAME} !-f
  # RewriteCond %{REQUEST_FILENAME} !-d
  # RewriteRule ^(.*)$ index.php?it=/http404/ [L,QSA]

  # -----------------------------------------------------------------------------------------------
  # 15. Access Restrictions: Protect ProcessWire system files
  # -----------------------------------------------------------------------------------------------

  # Allow screenshot files (for install.php only: this 1 line below may be removed after install)
  RewriteCond %{REQUEST_URI} !(^|/)site-[^/]+/install/[^/]+\.(jpg|jpeg|png|gif)$
  # Block access to any htaccess files
  RewriteCond %{REQUEST_URI} (^|/)\.htaccess$ [NC,OR]
  # Block access to protected assets directories
  RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$) [OR]
  # Block acceess to the /site/install/ directory
  RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/install($|/.*$) [OR]
  # Block dirs in /site/assets/ dirs that start with a hyphen
  RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets.*/-.+/.* [OR]
  # Block access to /wire/config.php, /site/config.php, /site/config-dev.php, and /wire/index.config.php
  RewriteCond %{REQUEST_URI} (^|/)(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php$ [OR]
  # Block access to any PHP-based files in /templates-admin/
  RewriteCond %{REQUEST_URI} (^|/)(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$ [OR]
  # Block access to any PHP or markup files in /site/templates/
  RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ [OR]
  # Block access to any PHP files in /site/assets/
  RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/assets($|/|/.*\.php)$ [OR]
  # Block access to any PHP files in core or core module directories
  RewriteCond %{REQUEST_URI} (^|/)wire/(core|modules)/.*\.(php|inc|tpl|module|info\.json)$ [OR]
  # Block access to any PHP files in /site/modules/
  RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module|info\.json)$ [OR]
  # Block access to any software identifying txt files
  RewriteCond %{REQUEST_URI} (^|/)(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md|textile)$ [OR]
  # Block all http access to the default/uninstalled site-default directory
  RewriteCond %{REQUEST_URI} (^|/)site-default/
  # If any conditions above match, issue a 403 forbidden
  RewriteRule ^.*$ - [F,L]

  # PW-PAGENAME
  # ----------------------------------------------------------------------------------------------- 
  # 16a. Ensure that the URL follows the name-format specification required by PW
  # See also directive 16b below, you should choose and use either 16a or 16b. 
  # ----------------------------------------------------------------------------------------------- 

  RewriteCond %{REQUEST_URI} "^/~?[-_.a-zA-Z0-9/]*$"
  
  # ----------------------------------------------------------------------------------------------- 
  # 16b. Alternative name-format specification for UTF8 page name support.
  # If used, comment out section 16a above and uncomment the directive below. If you have updated 
  # your $config->pageNameWhitelist make the characters below consistent with that. 
  # ----------------------------------------------------------------------------------------------- 
  
  # RewriteCond %{REQUEST_URI} "^/~?[-_./a-zA-Z0-9æåäßöüđжхцчшщюяàáâèéëêěìíïîõòóôøùúûůñçčćďĺľńňŕřšťýžабвгдеёзийклмнопрстуфыэęąśłżź]*$"
  
  # END-PW-PAGENAME
  # -----------------------------------------------------------------------------------------------
  # 17. If the request is for a file or directory that physically exists on the server,
  # then don't give control to ProcessWire, and instead load the file
  # ----------------------------------------------------------------------------------------------- 

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !(favicon\.ico|robots\.txt)

  # -----------------------------------------------------------------------------------------------
  # 18. OPTIONAL: Prevent ProcessWire from attempting to serve images or anything in /site/assets/. 
  # Both of these lines are optional, but can help to reduce server load. However, they
  # are not compatible with the $config->pagefileSecure option (if enabled) and they 
  # may produce an Apache 404 rather than your regular 404. You may uncomment the two lines
  # below if you don't need to use the $config->pagefileSecure option. After uncommenting, test
  # a URL like domain.com/site/assets/files/test.jpg to make sure you are getting a 404 and not
  # your homepage. If getting your homepage, then either: do not use this option, or comment out 
  # section #2 above that makes ProcessWire the 404 handler. 
  # ----------------------------------------------------------------------------------------------- 

  # RewriteCond %{REQUEST_FILENAME} !\.(jpg|jpeg|gif|png|ico)$ [NC]
  # RewriteCond %{REQUEST_FILENAME} !(^|/)site/assets/

  # ----------------------------------------------------------------------------------------------- 
  # 19. Pass control to ProcessWire if all the above directives allow us to this point.
  # For regular VirtualHosts (most installs)
  # ----------------------------------------------------------------------------------------------- 
  RewriteRule ^(.*)$ index.php?it=$1 [L,QSA]

  # ----------------------------------------------------------------------------------------------- 
  # 20. If using VirtualDocumentRoot (500 NOTE): comment out the one above and use this one instead
  # ----------------------------------------------------------------------------------------------- 
  # RewriteRule ^(.*)$ /index.php?it=$1 [L,QSA]

</IfModule>

#################################################################################################
# END PROCESSWIRE HTACCESS DIRECTIVES
#################################################################################################

 

Edited by sebr
anonymisation
Link to comment
Share on other sites

I didn't really read/scan your .htaccess file - I assume it's the default one that has been generated in the install process?

Do you have anything special in your config.php file?

"gestion" is the backend page-slug that works fine in your local dev install?

The only thing I can suggest without further infos right now: delete everything inside site/assets/cache/ folder

If that doesn't fix it, try to re-move / re-upload everything from dev to prod again. Perhaps some files or folders didn't make it?

Link to comment
Share on other sites

I deleted all folders in site/assets/cache but nothing better.

In my config.php :

<?php namespace ProcessWire;

/**
 * ProcessWire Configuration File
 *
 * Site-specific configuration for ProcessWire
 *
 * Please see the file /wire/config.php which contains all configuration options you may
 * specify here. Simply copy any of the configuration options from that file and paste
 * them into this file in order to modify them.
 *
 * SECURITY NOTICE
 * In non-dedicated environments, you should lock down the permissions of this file so
 * that it cannot be seen by other users on the system. For more information, please
 * see the config.php section at: https://processwire.com/docs/security/file-permissions/
 *
 * This file is licensed under the MIT license
 * https://processwire.com/about/license/mit/
 *
 * ProcessWire 3.x, Copyright 2016 by Ryan Cramer
 * https://processwire.com
 *
 */

if(!defined("PROCESSWIRE")) die();
ini_set('session.gc_probability', 1);

/*** SITE CONFIG *************************************************************************/

/** @var Config $config */

/**
 * Enable debug mode?
 *
 * Debug mode causes additional info to appear for use during dev and debugging.
 * This is almost always recommended for sites in development. However, you should
 * always have this disabled for live/production sites.
 *
 * @var bool
 *
 */
$config->debug = false;


/*** INSTALLER CONFIG ********************************************************************/


/**
 * Installer: Database Configuration
 *
 */

$config->dbHost = '###';
$config->dbName = '###';
$config->dbUser = '###';
$config->dbPass = '###';
$config->dbPort = '3306';
$config->chmodDir = '0755'; // permission for directories created by ProcessWire
$config->chmodFile = '0644'; // permission for files created by ProcessWire
$config->httpHosts = array('www.test.com');


/**
 * Installer: User Authentication Salt
 *
 * Must be retained if you migrate your site from one server to another
 *
 */
$config->userAuthSalt = 'fc4e33ee2fc1b999878c0cb3da87f2ce';

/**
 * Installer: File Permission Configuration
 *
 */

/**
 * Installer: Time zone setting
 *
 */
$config->timezone = 'Europe/Paris';
setlocale(LC_ALL, "fr_FR.UTF-8");


/**
 * Installer: Unix timestamp of date/time installed
 *
 * This is used to detect which when certain behaviors must be backwards compatible.
 * Please leave this value as-is.
 *
 */
$config->installed = 1510667390;


ini_set('session.gc_probability', 1);
$config->sessionFingerprint=false;

/**
 * Template prepend file
 *
 */
$config->prependTemplateFile = '_init.php';

 

Edited by sebr
anonymisation
Link to comment
Share on other sites

In the Filecompiler log :

2018-05-02 23:24:03	guest	https://www.test.com:443/gestion	Compiled file: /site/modules/MarkupCookieConsent/MarkupCookieConsent.config.php
2018-05-02 23:24:04	guest	https://www.test.com:443/gestion/login/	Compiled file: /site/modules/ProcessWireUpgrade/ProcessWireUpgradeCheck.module
2018-05-02 23:24:04	guest	https://www.test.com:443/gestion/login/	Compiled file: /site/modules/ProcessWireUpgrade/ProcessWireUpgradeCheck.config.php
2018-05-02 23:24:04	guest	https://www.test.com:443/	Compiled file: /site/templates/_init.php
2018-05-02 23:24:04	guest	https://www.test.com:443/	Compiled file: /site/templates/home.php
2018-05-02 23:24:04	guest	https://www.test.com:443/	Compiled file: /site/modules/ProcessMenuBuilder/MarkupMenuBuilder.module
2018-05-02 23:24:04	guest	https://www.test.comr:443/	Compiled file: /site/modules/FieldtypeFontIconPicker/InputfieldFontIconPicker.module
2018-05-02 23:24:04	guest	https://www.test.com:443/	Compiled file: /site/modules/FieldtypeFontIconPicker/Icons/FontAwesome.php

 I found /gestion/login/ but after I redirected to /

Edited by sebr
anonymisation
Link to comment
Share on other sites

22 minutes ago, sebr said:

The admin access is OK else not I have got the 404 page...

I'm not sure I understand. I can see your site (frontend) fine.

The admin access is OK: so you can login https://www.mairie-saintoffenge.fr/gestion now?

"else not 404" -> I don't understand that

Take a look at the first chapter in the troubleshooting guide: https://processwire.com/docs/tutorials/troubleshooting-guide/page2

If indeed you have backend-login now, try to clear modules cache.

Also, take a look at other log files than just Filecompiler (PW error log, or your Apache error log files)

Link to comment
Share on other sites

@dragan Sorry I'm not well expressed. I just wanted to say that if /gestion73100 was not recognized, I would have got a 404 error.

If I go to https://www.test.com/gestion (the admin path) I'am redirecting (302) to https://www.test.com/ (root path) without any option to login.

I already read this chapter about login troubleshooting but I don't find a solution...

In PW error log and Apache error log, I don't see anything bad.

I don't understand what happens. This morning all was good. I just installed PageimageRemoveVariations module. Is it possible to delete the last installed module : PageimageRemoveVariations ?

Edited by sebr
anonymisation
Link to comment
Share on other sites

  • I also tried to rename in the database the page ID 2 from "gestion" to "processwire" but the result is /processwire is redirecting to / without login form...
Edited by sebr
anonymisation
Link to comment
Share on other sites

OK. Then I downloaded all processwire folder from prod to dev. I dump the prod database and import it in the dev environnement.

And... It's the same thing on dev : when I go to the admin path I'm redirecting to root URL.

If I truncate the caches table in the dev database : I get the login form but lot off bugs because of the truncate caches table...

How can I do without this bad effect ?

Link to comment
Share on other sites

14 minutes ago, sebr said:

If I truncate the caches table in the dev database : I get the login form but lot off bugs because of the truncate caches table...

If you are able to log in you may be able to resolve the errors by rebuilding the modules cache at Modules > Refresh.

Related topic:

 

Link to comment
Share on other sites

5 hours ago, Robin S said:

If you are able to log in you may be able to resolve the errors by rebuilding the modules cache at Modules > Refresh.

Hi @Robin S

I read this post and I refresh Modules. But some module don't work anymore.

For example, I use AOIM and for CSS cal I have this error :

<br /><b>Warning</b>:  A non-numeric value encountered in <b>/home/srufer/public_html/client_mairiestoffenge/www/site/assets/cache/FileCompiler/site/modules/AllInOneMinify/AllInOneMinify.module</b> on line <b>713</b><br />
/site/assets/aiom/css_b828a2467647aa875f44be4891e380f6.css

 

Link to comment
Share on other sites

Them for AOIM module, I replaced in line 707 :

// ------------------------------------------------------------------------
// Initialize timestamp variable.
// ------------------------------------------------------------------------
$_timestamp = '';

By

// ------------------------------------------------------------------------
// Initialize timestamp variable.
// ------------------------------------------------------------------------
$_timestamp = 0;

And All is good !

  • Like 1
Link to comment
Share on other sites

  • sebr changed the title to Admin URL redirect to root URL

OK Then Don't work :

  1. I truncate table caches
  2. I go to /gestion and I refresh modules twice
  3. I'm signing out and I go to www.test.com (Root URL)
  4. I go to /gestion and I'm redirecting to root url again !

So I don't understand why !

Link to comment
Share on other sites

If I followed correct, you have a well running local site?

You plain copied it to the online space? (Without running an installer before?)

Maybe you can try to export your local site with the SiteProfileExporter Module, and then do a fresh installation online. But be aware, that all created roles & users & accessrights get not exported with the SiteProfileExporter Module. This you have to implement manually after installation.

The advantage is that you don't have to deal with all the different caches and also get notifications during the installation routine if something with the online space is missing.

Edited by horst
added Link to exporter module
  • Like 1
Link to comment
Share on other sites

Hi @horst. I just tried your solution. I installed SiteProfileExporter module on production website. I created a backup. I installed on dev a new Processwire install with this site profile, but in the end of the install process, I clicked on "Login To admin" button. Then no admin login form, just a redirection to the home page !

This solution don't work !

Link to comment
Share on other sites

Houra !!!

I don't know why, but in the MaintenanceMode module from @Pete, I get a buggy value.

  1. I set the field "Redirect to another URL" to "/waiting.html".
  2. The maintenance mode was disable
  3. but I have strange value in the filed "Redirect to another page instead of the login page?" : it was set to "Login" and impossible to change it.

I just uninstalled and install again the module and now all is OK !

Thanks a lot for your help @dragan, @Robin S and @horst

  • Like 1
Link to comment
Share on other sites

  • sebr changed the title to [SOLVED] Admin URL redirect to root URL

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...