Enabling URL rewriting gives 404 error

Discuss Search Engine Optimization in relation to Joomla! 3.x. This forum will also have discussions on SEF/SEO Joomla! 3.x extensions.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
planteg
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Aug 02, 2017 9:03 pm

Enabling URL rewriting gives 404 error

Postby planteg » Mon Aug 28, 2017 9:46 pm

Hi,

I searched the forum and found out I am not alone with this, but was not able to find a solution. Here are the specifics of my installation:

Joomla! Version Joomla! 3.7.5 Stable
Joomla! Platform Version Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
PHP Version 5.6.30-0+deb8u1
Web Server Apache/2.4.10 (Raspbian)
WebServer to PHP Interface apache2handler
Database Version 5.5.57-0+deb8u1

Database is mySQL.

The installation is on a test machine to learn and practice Joomla!

Like others, I would like to hide index.php, instead of that I got 404 error :( .

I followed directions found here: https://docs.joomla.org/Enabling_Search_Engine_Friendly_(SEF)_URLs

What I have done is:

  • Rename /html/htaccess.txt to /html/.htaccess
  • Enabled the rewrite module in Apache2
  • Enable Plugin System - SEF (was already enabled)
  • Search Engine Friendly URLs set to Yes
  • Use URL Rewriting set to Yes
  • Adds Suffix to URL set to Yes

What is missing ? I remember last year testing CodeIgniter that I had a hard time doing the same.

Thanks

Gilles Plante

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Mon Aug 28, 2017 10:00 pm

Did you restarted Apache?
chat room spontes : http://www.spontes.com

planteg
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Aug 02, 2017 9:03 pm

Re: Enabling URL rewriting gives 404 error

Postby planteg » Mon Aug 28, 2017 10:11 pm

Yes, I even rebooted the computer. What is the best way to debug this ? I turned on debugging, but nothing is displayed on the front end since I get 404.

The message for http://192.168.1.113/en/about.html is /en/about.html was not found on this server.

Looks like internally index.php is not added, which rewriting is all about.

Gilles Plante

User avatar
sozzled
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3498
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: Enabling URL rewriting gives 404 error

Postby sozzled » Mon Aug 28, 2017 10:22 pm

https://www.kuneze.com/blog
Former member of Kunena project team
If you think I’m wrong then say “I think you're wrong.” If you say “You’re wrong!”, how do you know?

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Mon Aug 28, 2017 10:49 pm


Different problem. Please read the OP again.
chat room spontes : http://www.spontes.com

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Mon Aug 28, 2017 10:50 pm

planteg wrote:Yes, I even rebooted the computer. What is the best way to debug this ? I turned on debugging, but nothing is displayed on the front end since I get 404.

The message for http://192.168.1.113/en/about.html is /en/about.html was not found on this server.

Looks like internally index.php is not added, which rewriting is all about.

Gilles Plante

Please give us a url to have a look
chat room spontes : http://www.spontes.com

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Mon Aug 28, 2017 10:59 pm

planteg wrote:Yes, I even rebooted the computer.

Are you local to your pc? If you disable url rewriting in joomla backend do you get a 404 error?
chat room spontes : http://www.spontes.com

User avatar
sozzled
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3498
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: Enabling URL rewriting gives 404 error

Postby sozzled » Mon Aug 28, 2017 11:02 pm

@ribo: read this:
planteg wrote:The message for http://192.168.1.113/en/about.html is /en/about.html was not found on this server.
If the site is monolingual and the language filter is enabled then viewtopic.php?f=712&t=954043 applies. It may be a "different problem"—it probably isn't—but I was only trying to help.

And, if you read the OP yourself you would see that the issue relates to a locally-hosted website. :p
https://www.kuneze.com/blog
Former member of Kunena project team
If you think I’m wrong then say “I think you're wrong.” If you say “You’re wrong!”, how do you know?

planteg
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Aug 02, 2017 9:03 pm

Re: Enabling URL rewriting gives 404 error

Postby planteg » Mon Aug 28, 2017 11:54 pm

It's a local computer on my home network but I can use port forwarding if you want to connect.

The site is multi-lingual (it's the exercise from lynda.com course). I will create a real site once I am done with some experiments, like rewriting, that will also be multi-lingual. This real site will hosted on a real server.

If I disable rewriting, all is well. I have same results whether I use Chromium on the site computer or Chrome on another computer.

Looking at the link you provided, multi-lingual seems to play a role in my issue. Things is I will need the "System - Language Filter" plugin enabled on my real site.

Thanks for your help.

Gilles Plante

planteg
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Aug 02, 2017 9:03 pm

Re: Enabling URL rewriting gives 404 error

Postby planteg » Tue Aug 29, 2017 12:39 am

I may have found something, looking at /var/log/apache2/access.log.The last entry is (timestamp and ip removed):

Code: Select all

"GET /en/about HTTP/1.1"
404 506 "http://192.168.1.113/index.php/en/"
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36"

I added a few line feeds to make it easier to read. It looks like 192.168.1.113/en/about is rewritten in 192.168.1.113/index.php/en/, that is index.php is added, BUT the last part of the URL is removed. Missing in that example about will for sure not work. The is it the content of .htaccess that would be wrong ? Here is the contents:

Code: Select all

## No directory listings
<IfModule autoindex>
  IndexIgnore *
</IfModule>

## Can be commented out if causes errors, see notes above.
Options +FollowSymlinks
Options -Indexes

## Mod_rewrite in use.

RewriteEngine On

## Begin - Rewrite rules to block out some common exploits.
# If you experience problems on your site then comment out the operations listed
# below by adding a # to the beginning of the line.
# This attempts to block the most common type of exploit `attempts` on Joomla!
#
# Block any script trying to base64_encode data within the URL.
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
# Block any script that includes a <script> tag in URL.
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
# Block any script trying to set a PHP GLOBALS variable via URL.
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block any script trying to modify a _REQUEST variable via URL.
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Return 403 Forbidden header and show the content of the root home page
RewriteRule .* index.php [F]
#
## End - Rewrite rules to block out some common exploits.

## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects

##
# Uncomment the following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root).
##

RewriteBase /

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.

Gilles Plante

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Tue Aug 29, 2017 1:26 am

planteg wrote: (it's the exercise from lynda.com course).

What do you mean? From where did you download joomla?
chat room spontes : http://www.spontes.com

planteg
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Aug 02, 2017 9:03 pm

Re: Enabling URL rewriting gives 404 error

Postby planteg » Tue Aug 29, 2017 2:21 am

Joomla! was downloaded from jommla.com and installed as supposed.

The course provides some text files and images to be used for the articles. That's it that's all.

Now can we be back to my issue please ? I know many of you attach a great importance to the way Joomla! is installed. But it has been installed correctly.

Do I look angry ? Yes. I come to the forum to get help, not to get a lecture each time. Now, did I pick the wrong CMS for my Web site ? I hope not. And by the way, that course on lynda.com is very good for some one who starts from scratch.

I am truly sorry about this, but boy, do are some here very suspicious.

Thanks again,

Gilles Plante

User avatar
sozzled
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3498
Joined: Sun Jul 05, 2009 3:30 am
Location: Canberra, Australia
Contact:

Re: Enabling URL rewriting gives 404 error

Postby sozzled » Tue Aug 29, 2017 2:52 am

@planteg: For a multilingual Joomla website you will need to install the additional language packs (as you require them) and then use the Components » Multilingual Associations component in the backend as you require. As far as getting the third-degree is concerned, @ribo gives me a difficult time, too.

BTW, when you wrote that you downloaded Joomla from "joomla.com", I assume you meant joomla.org?

I'm not experienced with using Joomla multilingual websites. I take my cues from the experts and, most of the time, I just quote what I read on the forum. It shouldn't be difficult but it's outside my field of expertise. Perhaps @ribo can enlighten all of us about why you get the message "/en/about.html was not found on this server"?

As an aside, even though you can "Adds Suffix to URL set to Yes", it's unnecessary and most Joomla websites that I visit don't do it. There's no downside to doing it, if you want; I'm just saying, that's all. 8)
https://www.kuneze.com/blog
Former member of Kunena project team
If you think I’m wrong then say “I think you're wrong.” If you say “You’re wrong!”, how do you know?

arkangel75ar
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Aug 29, 2017 7:25 am

Re: Enabling URL rewriting gives 404 error

Postby arkangel75ar » Tue Aug 29, 2017 7:30 am

Hi,
i found this page https://www.digitalocean.com/community/ ... od_rewrite

works for me! :geek:

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Tue Aug 29, 2017 10:57 am

planteg wrote:Joomla! was downloaded from jommla.com and installed as supposed.

The course provides some text files and images to be used for the articles. That's it that's all.

Now can we be back to my issue please ? I know many of you attach a great importance to the way Joomla! is installed. But it has been installed correctly.

Do I look angry ? Yes. I come to the forum to get help, not to get a lecture each time. Now, did I pick the wrong CMS for my Web site ? I hope not. And by the way, that course on lynda.com is very good for some one who starts from scratch.

I am truly sorry about this, but boy, do are some here very suspicious.

Thanks again,

Gilles Plante

My ask about where do you downloaded joomla package is because many sites change the files inside of joomla package for their needs and they have not the same original package. That s why i asked. I am not lecture to you.
Now another ask for you is what local server do you use?
chat room spontes : http://www.spontes.com

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Tue Aug 29, 2017 11:11 am

sozzled wrote:@planteg: As far as getting the third-degree is concerned, @ribo gives me a difficult time, too.

I'm not experienced with using Joomla multilingual websites. I take my cues from the experts and, most of the time, I just quote what I read on the forum. It shouldn't be difficult but it's outside my field of expertise. Perhaps @ribo can enlighten all of us about why you get the message "/en/about.html was not found on this server"?

As an aside, even though you can "Adds Suffix to URL set to Yes", it's unnecessary and most Joomla websites that I visit don't do it. There's no downside to doing it, if you want; I'm just saying, that's all. 8)

I dont give you difficult time to you but you give difficult time to your shelf as you said that you are not experienced with using Joomla multilingual websites and you post something that is not familiar with the OP. Also about "Adds Suffix to URL set to Yes" this is not a problem in his issue as the only thing that it do is that it put a .html at the end of a url. The problem of OP seems to be a server configuration issue except if the joomla package is not downloaded from joomla.org https://downloads.joomla.org/ and have the chance to be problematic or if the htaccess.txt not renamed well.
Last edited by ribo on Tue Aug 29, 2017 12:53 pm, edited 2 times in total.
chat room spontes : http://www.spontes.com

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Tue Aug 29, 2017 12:27 pm

planteg wrote:
Do I look angry ? Yes. I come to the forum to get help, not to get a lecture each time. Now, did I pick the wrong CMS for my Web site ? I hope not. And by the way, that course on lynda.com is very good for some one who starts from scratch.


If you don t understand the point of a question don t make wrong conclusions. If you want to find solution to your isues be patient. That s an advice. About your issue before we will believe that the problem can be in the local server please make a test. Download joomla 3.7.5 from https://downloads.joomla.org/ , and install a fresh joomla and rename htaccess.txt to .htaccess(double check that is renamed well, as i saw in pc that sometimes even if you rename htaccess.txt to .htaccess it s not save the "." in front of htaccess). Then create a test article and after create a menu item for this article and use rewrite from global congiguration. If you want to install it from the begin as multilanguage the install has steps for this as well. Note that you must install all the languages that you want in multilanguage in the joomla install progress.
chat room spontes : http://www.spontes.com

planteg
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Aug 02, 2017 9:03 pm

Re: Enabling URL rewriting gives 404 error

Postby planteg » Tue Aug 29, 2017 1:48 pm

@ribo

Jommla! was downloaded from joomla.org (@sozzled, I made a typo about joomla.com) and installed the right way. Before re-installing I want to look at the clues I have, and they are in the .htaccess I included in a previous post.

Joomla! is installed on Linux, so .htaccess was properly named that way. Joomla! runs on lamp. The setting that adds the suffix has been turned off. The setup for handling multi-languages has been done per instructions in the course and works fine when URL rewriting is not enabled.

<@ribo and @sozzled, please have a look at .htaccess that I added to my post Mon Aug 28, 2017 8:39 pm. If you are in a different time zone, then the time and date could be different. That would be nice if posts were numbered.

Now back to the issue, I think I found out something else. The real about page address is:

http://<domain or address>/index.php/about

for a standard site. Note that there are 2 segments after domain. Now for a multi-lingual site, the address (without rewriting) is:

http://<domain or address>/index.php/en/about

The language adds a segment, a two letter code. Now with URL rewrite, the address will be:

http://<domain or address>/en/about

and rewrite should insert the missing index.php... it does but strip the last segment and generate:

http://<domain or address>/index.php/en

and that for sure can't be found. I found that looking at the log. Looks like the rewriting process works to have only two segments following the site.

@sozzled, you thought that the issue may have to do with multi-lingual, and you guessed right ! I will google to see if I can find something on the matter.

Thanks to both of you

Gilles Plante

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Tue Aug 29, 2017 2:06 pm

If you think that your multilanguage is your problem, then try this: go to extensions-plugins-System - Language Filter-Remove URL Language Code and put this Yes. Then if you have english language as default in the site and you have rewrite enabled in global configuration then the
http://<domain or address>/index.php/about
must change to
http://<domain or address>/about
Is this change?
chat room spontes : http://www.spontes.com

planteg
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Aug 02, 2017 9:03 pm

Re: Enabling URL rewriting gives 404 error

Postby planteg » Tue Aug 29, 2017 2:35 pm

I have done the suggested change and yes, I get http://<domain or address>/about in the addresse bar, but still page not found. From the log:

Code: Select all

"GET /about HTTP/1.1" 404 503 "http://192.168.1.113/"

So the rewrite produces http://192.168.1.113/ which is the Home page in English, and that should work ?!?

Gilles Plante

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Tue Aug 29, 2017 4:51 pm

planteg wrote:I have done the suggested change and yes, I get http://<domain or address>/about in the addresse bar, but still page not found. From the log:

Code: Select all

"GET /about HTTP/1.1" 404 503 "http://192.168.1.113/"

So the rewrite produces http://192.168.1.113/ which is the Home page in English, and that should work ?!?

Gilles Plante

When you make the suggested change you must have the home page of default language http://<domain or address>/ and the in about menu item for default language must be http://<domain or address>/about and in this menu item you still have 404 error, so as you understand the problem is not in multilanguage.
Now please try this in your pc with windows. Try to install in your pc xampp or wamp server or uniform server http://www.uniformserver.com/ and install there a joomla site and see if there the rewrite works. I recommend uniform server.
chat room spontes : http://www.spontes.com

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Tue Aug 29, 2017 6:11 pm

planteg wrote: Before re-installing I want to look at the clues I have, and they are in the .htaccess I included in a previous post.


Also about the content of .htaccess must be the same with the content of htaccess.txt in joomla 3.7.5 full package.
chat room spontes : http://www.spontes.com

planteg
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Aug 02, 2017 9:03 pm

Re: Enabling URL rewriting gives 404 error

Postby planteg » Sat Sep 02, 2017 8:04 pm

Ah, that makes a lot of sense ! I downloaded the full install of 3.75 but couldn't find htaccess.txt. Unfortunately xpackager doesn't include a search functionality. Do you happne to know where the file is located ? Reading here and there, it looks like upgrading Joomla! may bring some issues.

I will have a look at my backups (by Akeeba), I should have one made before upgrading to 3.7.5. If so I may bring it back and see if the issue still exists (at the time of the backup, URL rewriting was not enabled).

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Mon Sep 04, 2017 4:26 pm

planteg wrote: I downloaded the full install of 3.75 but couldn't find htaccess.txt. Unfortunately xpackager doesn't include a search functionality. Do you happne to know where the file is located ?

If you will download the joomla 3.7.5 stable-full package from https://downloads.joomla.org/ and open the zip file with a zip programm you will see folders and files. One of the files out of the folders is htaccess.txt. None update of joomla brings issues in .htaccess. Did you tryed some of the programs that i told you in windows 7 to see that your problem is not a joomla issue. If you still want to be with linux try if you want to webhosting for one month(the cost will not big) to understand that your problem is not a joomla issue.
chat room spontes : http://www.spontes.com

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 23669
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: Enabling URL rewriting gives 404 error

Postby Per Yngve Berg » Mon Sep 04, 2017 6:30 pm

I think the issue with rewrite is that you don't have a domain name. Rewrite does not work properly with temporary URL.

planteg
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Aug 02, 2017 9:03 pm

Re: Enabling URL rewriting gives 404 error

Postby planteg » Mon Sep 11, 2017 6:49 pm

Hi Per Yngve Berg,

how could I check for that ?

@ribo, if I install everything either on WAMP or another computer with LAMP, bringing the website to the other computer will bring back Joomla!, so that would not be starting from scratch.

Gilles Plante

User avatar
ribo
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3077
Joined: Sun Jan 03, 2010 8:47 pm
Contact:

Re: Enabling URL rewriting gives 404 error

Postby ribo » Mon Sep 11, 2017 10:39 pm

planteg wrote:
@ribo, if I install everything either on WAMP or another computer with LAMP, bringing the website to the other computer will bring back Joomla!, so that would not be starting from scratch.

I was just said to install wamp or uniform server and configure it with mod_rewrite to a windows 7 pc and transfer there your joomla website with the original .htaccess to see if the problem is in your lamp server
https://docs.joomla.org/Copying_a_Joomla_website. In there you will have http://localhost/yourwebsite
chat room spontes : http://www.spontes.com

planteg
Joomla! Apprentice
Joomla! Apprentice
Posts: 35
Joined: Wed Aug 02, 2017 9:03 pm

Re: Enabling URL rewriting gives 404 error

Postby planteg » Tue Sep 26, 2017 9:26 pm

Hi,

my issue is now solved. The problem was so simple... well easy to say once you know what it is ;) .

So the issue was the .htaccess file. For some reason, it was not used, even though everything else was properly set. I tried a zillion of things, to no avail.

Then a few days ago imanickam offered to help me (from another post) which brought me to play with .htaccess since on its side after restoring the site from a backup all was fine. So today I hide it (renamed) to see if there would be a difference. And there were none. I brought back .htaccess to life and then it worked. Can't tell what was wrong with it, but once it was used all was fine. Googling here and there I found out that .htaccess has to be enabled for apache, but the way to do it depends on specific distribution of Linux... oh the joys of Linux :'( .

With the help of the forum members, I finally got it to work.

Thanks


Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 3.x”

Who is online

Users browsing this forum: husenbisri and 5 guests