php - htaccess https rewrite issue when trying to login to cmsms


I am having some issues with my rewrite rules since moving to a new server. Our previous server was Apache 2.2.13 with PHP 5.2.11, the new server is Apache 2.2.25 with PHP 5.4.18.

I am ensuring all traffic is transferred to www. and https

The redirects work fine for users, but when I try to login to cmsms, I enter my username and password and click login and the page refreshes, clearing the username and password boxes rather than logging into admin. I can login if I remove the following from the htaccess file.

This is what is in the htaccess file.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Options +FollowSymLinks
RewriteCond %{THE_REQUEST} ^.*/home
RewriteRule ^(.*)home$$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$$1 [R=301,L]

I had some issues with the php.ini that I had transferred across so replaced it with this, maybe I need more?:

register_globals = off
date.timezone = Europe/London
output_buffering = 1
;zend_extension = /usr/local/ioncube/
post_max_size = 20M
memory_limit = 200M
upload_max_filesize = 20M
max_execution_time = 120
expose_php = off
session.save_path = /tmp
magic_quotes_gpc = Off
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED?????????????????

Thanks for your help




Well, from my point of view, of course, your "problem" is caused by:

  • (updated) apache rewrite module in new version of apache (what is normal for apache updates anyway) and of course, IF your script have been working fine at - previous server.

You might give it a try by removing (or playing around with) these lines away, for a start at least;

RewriteRule ^(.*)home$$1 [R=301,L]
RewriteRule ^(.*)index.php$$1 [R=301,L]

assuming that your php script supports upcoming URI changes after this. If that will work, get you logged in (and your users will have problems), deal is to write those lines back and a codework for your login panel to obey new rewrite rules.

Anyway I would not recommend to mess up php.ini until this apache problem is solved up.

Note: This kind of your problem and behavior was/is normal for register globals also, but that function is completely removed starting from php 5.4.0 and that kind of an "option" was/is used in quite old scripts.

People are also looking for solutions to the problem: php - Find nearest "parameter 2" that appears before "parameter 1" when searching through a file


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.