Tuesday, April 30, 2019
Tuesday, April 2, 2019
Joomla SEF URL Problems [SOLVED 404 Error]
Hello Everyone,
Recently my team and I worked and delivered a small Joomla website. After the site went live, I turned ON the SEF URL from the backend. But the URLs was still non-search engine friendly. I started to troubleshoot, finally, it started to work. I decided to document the steps through which it worked for me and the following are the steps. My intent is to educate.
Please note,
- These steps are for an Ubuntu machine running Apache2 and I am using Joomla 3.X
- Application is hosted at folder /var/www/html/JoomlaApp/
- Demo URL for my site will be http://siteurl.com/JoomlaApp/
Preliminary checks or requirements
- MOD_REWRITE: Very first step is to make sure mod_rewrite is enabled. By use of phpinfo(); one can verify if it is enabled or not. If it does not then use the command
sudo a2enmod rewrite and then restart the web server. - Rename htaccess.txt: Joomla provides its users with a default htacess.txt file. In order to enable SEF URL's this file needs to be renamed to .htaccess
- Apache Configurations: The apache configuration needs to change so that it allows URL rewrites. I made changes for both HTTP & HTTPS configuration that is port 80 & 443.
- /etc/apache2/sites-available/000-default.conf
- <VirtualHost *:80>
- ServerAdmin webmaster@localhost
- DocumentRoot /var/www/html
- <Directory "/var/www/html">
- AllowOverride All
- </Directory>
- /etc/apache2/sites-available/default-ssl.conf
- <VirtualHost _default_:443>
- ServerAdmin webmaster@localhost
- DocumentRoot /var/www/html
- <Directory "/var/www/html">
- AllowOverride All
- </Directory>
- Joomla Admin Configuration change
- Log into Joomla Admin console
- Go to System > Global Configuration
- Locate SEO Settings and set the Use URL Rewriting option to Yes
As per Joomla documentation, the above steps should enable the SEF URL for your website, if it doesn't work then follow are the troubleshooting steps.
- Apache Configuration: As a habit, I copied the AllowOverride All code directly from the net and pasted it on the Apache configuration file. Which was a mistake. Apache configuration is very particular about the double quotes. "". Hence please type it, do not copy paste it.
- I made the following changes to my .htaccess file.
- Uncommented # RewriteBase / to RewriteBase /
- My Joomla application exists inside another directory, like /var/www/html/JoomlaApp/. So I made the following change on Rewite Base
- RewriteBase /JoomlaApp/
- Added following piece of code after RewriteEngine On
- ## Mod_rewrite in use.
- RewriteEngine On
- RewriteCond %{HTTP_HOST} ^siteurl.com/JoomlaApp/ [NC]
- RewriteRule ^(.*)$ http://siteurl.com/JoomlaApp/$1 [L,R=301]
- Finally added following line of code at the very end of the file.
- RedirectMatch 301 ^/index.php/(.*)$ http://siteurl.com/JoomlaApp/$1
- Another change I made was to the configurations.php file. I initialized the Live site variable as following, I am not sure, how helpful this particular change was, but it is there in the mix.
- var $live_site = 'http://siteurl.com/JoomlaApp';
With all the above changes, the URL SEF for Joomla started to work for me. Please feel free to ask me any questions.
Thanx
Anshumaan Bakshi
Friday, June 17, 2016
AWS EC2 Apache File upload and move issue [RESOLVED]
Hello Everyone,
If you have purchased a fresh new instance on AWS which runs RHEL 7+.
And you are running PHP based application and trying to upload a file and also to move the uploaded file from tmp folder to a desired folder using. PHP functions like
copy() or move_uploaded_file()
Now while trying to achieve above you are getting permissions errors and warnings.
You have tried everything like giving all folder permission as 777 and made Apache the user and group owner for every file and directory under /var/www/html. And if still no joy then my friend you are a victim of SELinux.
I banged my head for hours figuring why this simple and straight forward is not working. Finally found RHEL 7+ got SELinux installed and enabled by default. And SELinux blocks Apache to move files irrespective it is part of the same group as the folder permissions are set.
So you have same issue then start by checking if it is enabled by command:
/usr/sbin/sestatus
The first row will say the status of SELinux, if enabled it will say enabled. And if it is enabled then most probably the reason for Apache not able to move files.
For fixing the issue just need to disable it, open the config file for SELinux:
vi /etc/selinux/config
If you have purchased a fresh new instance on AWS which runs RHEL 7+.
And you are running PHP based application and trying to upload a file and also to move the uploaded file from tmp folder to a desired folder using. PHP functions like
copy() or move_uploaded_file()
Now while trying to achieve above you are getting permissions errors and warnings.
You have tried everything like giving all folder permission as 777 and made Apache the user and group owner for every file and directory under /var/www/html. And if still no joy then my friend you are a victim of SELinux.
I banged my head for hours figuring why this simple and straight forward is not working. Finally found RHEL 7+ got SELinux installed and enabled by default. And SELinux blocks Apache to move files irrespective it is part of the same group as the folder permissions are set.
So you have same issue then start by checking if it is enabled by command:
/usr/sbin/sestatus
The first row will say the status of SELinux, if enabled it will say enabled. And if it is enabled then most probably the reason for Apache not able to move files.
For fixing the issue just need to disable it, open the config file for SELinux:
vi /etc/selinux/config
And find a variable named SELINUX and set it as
SELINUX=disabled
I tried SELINUX=permissive but no joy with it.
Then need to restart the system to take effect. Following works well on AWS.
shutdown -r now
After restarting it did resolved the problem.
I did server hardening like, Permissions and ownership's I changed, I changed them back and checked once again and everything worked well.
Do check and let me know in comments if any other issue you faced,
Thanx
Anshumaan Bakshi
Thursday, January 7, 2016
MySQL group_concat is causing trouble in getting output
Hello,
I was trying to get a long list of IDs against some value together by using group_concet comnad but there was some issue as the list I was getting was incomplete and every time I executed the command some values were missing.
I Googled for this issue and found that there is a MySQL session variable named group_concat_max_len which has a limit enforced by default to 1024, and it will not let anything beyond the enforced limit.
So, simple solution was to increase this limit to suit my need,
the command is I used is following:
SET SESSION group_concat_max_len = 1000000;
I was trying to get a long list of IDs against some value together by using group_concet comnad but there was some issue as the list I was getting was incomplete and every time I executed the command some values were missing.
I Googled for this issue and found that there is a MySQL session variable named group_concat_max_len which has a limit enforced by default to 1024, and it will not let anything beyond the enforced limit.
So, simple solution was to increase this limit to suit my need,
the command is I used is following:
SET SESSION group_concat_max_len = 1000000;
This needs to be executed for every MySQL session or needed to be declared in my.ini file for permanent usage.
Tested it works like a charm.
Thanx
Anshumaan Bakshi
Friday, July 10, 2015
Unable to enable crypto on TCP connection api.xxx.com make sure the sslcapath option points to a valid SSL certificate directory
This summary is not available. Please
click here to view the post.
Wednesday, June 24, 2015
SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1
Hello,
Got this error message
SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1
We tried everything to insert in one table but this error didn't budged even for the simplest query we wrote.
Then I found that there was a "TRIGGER" applied on this table which on insertion updates another table.
So the problem was with the stored procedure. There was some additional field in it.
I discovered the root cause as soon as I deleted the Trigger.
So the issue was with the error message, this error was not pin pointing that the field was missing on which table, due to the language of the error it seems like the error is with the immediate table but actually it can be with a connected one.
Hope this will help someone.
Thanx
Anshumaan Bakshi
Got this error message
SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1
We tried everything to insert in one table but this error didn't budged even for the simplest query we wrote.
Then I found that there was a "TRIGGER" applied on this table which on insertion updates another table.
So the problem was with the stored procedure. There was some additional field in it.
I discovered the root cause as soon as I deleted the Trigger.
So the issue was with the error message, this error was not pin pointing that the field was missing on which table, due to the language of the error it seems like the error is with the immediate table but actually it can be with a connected one.
Hope this will help someone.
Thanx
Anshumaan Bakshi
Monday, April 27, 2015
Connection Failed: 'host' is not allowed to connect to this mysql server
Hello,
If you are getting following error while trying to connect your (PHP) application to a MySQL database
Connection Failed: 'host' is not allowed to connect to this MySQL server
Then this may due to limited privileges given to the user through which one s trying to connect with the server. Although a correct username and password is been used to connect still we have this error.
What happens is when a new MySQL user is added to a DB then the hostname name like localhost is added by default to user like user1@localhost. Now this user can access the DB for sure but while he is on the same machine not remotely.
The solution for this issue is to create a new user which has Any Host privileges "%" like
mysql> CREATE USER 'user2'@'%' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user2'@'%' -> WITH GRANT OPTION;
Thanx
Anshumaan Bakshi
If you are getting following error while trying to connect your (PHP) application to a MySQL database
Connection Failed: 'host' is not allowed to connect to this MySQL server
Then this may due to limited privileges given to the user through which one s trying to connect with the server. Although a correct username and password is been used to connect still we have this error.
What happens is when a new MySQL user is added to a DB then the hostname name like localhost is added by default to user like user1@localhost. Now this user can access the DB for sure but while he is on the same machine not remotely.
The solution for this issue is to create a new user which has Any Host privileges "%" like
mysql> CREATE USER 'user2'@'%' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user2'@'%' -> WITH GRANT OPTION;
Thanx
Anshumaan Bakshi
Subscribe to:
Posts (Atom)