htaccess customisation for variables

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.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
FedWeb
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat Mar 17, 2018 9:45 pm

htaccess customisation for variables

Post by FedWeb » Sat Mar 17, 2018 10:12 pm

I am using Joomla 3.8.x and have SEF url enabled and am trying to turn
www.example.com/location?loc=london in to
www.example.com/site/london

I have googled this and looked on this forum, but everything I've seen and tried seems to fail.

I understand that I need to add a rewrite rule in the .htaccess file, after the common exploits and before the SEF. But whatever I do it keeps coming up with a 404 error. (I use caching, but turn this off when making changes to the file)

This is the latest version I have tried to no avail. Please can someone help me before insanity sets in :eek:

Thanks for any help you can provide.

Code: Select all

Options +FollowSymLinks
RewriteEngine on
## Check for https
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,NC]
## Rewrite the location url
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^site/(\d+)*$ ./loc?l=$1[L]

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

Re: htaccess customisation for variables

Post by Per Yngve Berg » Sat Mar 17, 2018 11:21 pm

What component is producing the URL? It must be handled by the router.php in the component.

FedWeb
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat Mar 17, 2018 9:45 pm

Re: htaccess customisation for variables

Post by FedWeb » Sat Mar 17, 2018 11:24 pm

The component producing the (location) URL is Jumi. And the script in Jumi handles the ?loc=london variable. Essentially if the town/city is valid then it shows a location page for a company.

FedWeb
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat Mar 17, 2018 9:45 pm

Re: htaccess customisation for variables

Post by FedWeb » Mon Mar 19, 2018 5:24 pm

Hi
Did I answer your question fully? Please let me know if I can make this any clearer. Thanks

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

Re: htaccess customisation for variables

Post by Per Yngve Berg » Mon Mar 19, 2018 5:58 pm

sorry, I am unfamiliar with Jumi.

FedWeb
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sat Mar 17, 2018 9:45 pm

Re: htaccess customisation for variables

Post by FedWeb » Mon Mar 19, 2018 6:27 pm

Sorry in advance if this is a silly question, but does it matter what component it is? Surely, .htaccess takes the URL and rewrites it so that the component can deal with it as normal.

so the site can handle domain.com/loc?l=london perfectly well. I just need it to look a little better i.e. without the ?l= in the URL

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

Re: htaccess customisation for variables

Post by Per Yngve Berg » Mon Mar 19, 2018 7:12 pm

SEF URLs have to be supported by the component. It's handled by the router.php file inside the component. It's not something you put in the .htaccess file.

kev211
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Tue Feb 27, 2018 10:20 am

Re: htaccess customisation for variables

Post by kev211 » Wed Mar 21, 2018 10:52 am

"Little Helper, by Riccardo Zorn - Joomla Extension Directory"

best one .htaccess .. just try it out and let me know


Locked

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