I just tested that url and it works fine.
Cool so youâll just need to remap your assets correctly including css, js etc
Adding the forward slash worked. The Images have returned however the Url still hasnât changed.
Ok so letâs implement Friendly URLs!
I think, turn them on in htaccess, and turn them on in system settings (the gear icon on the top right), and it should work! I hope I didnât miss anything.
These system settings actually exist, sorry about before The are in core-Friendly URLS
I have tried enabling htem in system settings and the .htaccess file but still nothing. Could there be something wrong with my .htaccess file?
Well, letâs take a look at it, could you post it here?
# MODX supports Friendly URLs via this .htaccess file. You must serve web
# pages via Apache with mod_rewrite to use this functionality, and you must
# change the file name from ht.access to .htaccess.
#
# Make sure RewriteBase points to the directory where you installed MODX.
# E.g., "/modx" if your installation is in a "modx" subdirectory.
#
# You may choose to make your URLs non-case-sensitive by adding a NC directive
# to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
RewriteEngine On
RewriteBase /
# Prevent dot directories (hidden directories like .git) to be exposed to the public
# Except for the .well-known directory used by LetsEncrypt a.o
RewriteRule "/\.|^\.(?!well-known/)" - [F]
# Rewrite www.example.com -> example.com -- used with SEO Strict URLs plugin
#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
#RewriteRule (.*) http://aircaretechnology.co.uk/$1 [R=301,L]
#
# or for the opposite example.com -> www.example.com use the following
# DO NOT USE BOTH
#
#RewriteCond %{HTTP_HOST} !^$
#RewriteCond %{HTTP_HOST} !^www\. [NC]
#RewriteCond %{HTTP_HOST} (.+)$
#RewriteRule (.*) http://www.aircaretechnology.co.uk/$1 [R=301,L]
# Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
# https://www.aircaretechnology.co.uk when your cert only allows https://aircaretechnology.co.uk
#RewriteCond %{SERVER_PORT} !^443
#RewriteRule (.*) https://aircaretechnology.co.uk/$1 [R=301,L]
# Redirect the manager to a specific domain - don't rename the ht.access file
# in the manager folder to use this this rule
#RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
#RewriteCond %{REQUEST_URI} ^/manager [NC]
#RewriteRule ^(.*)$ https://aircaretechnology.co.uk/$1 [R=301,L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# Make sure .htc files are served with the proper MIME type, which is critical
# for XP SP2. Un-comment if your host allows htaccess MIME type overrides.
#AddType text/x-component .htc
# If your server is not already configured as such, the following directive
# should be uncommented in order to set PHP's register_globals option to OFF.
# This closes a major security hole that is abused by most XSS (cross-site
# scripting) attacks. For more information: http://php.net/register_globals
#
# To verify that this option has been set to OFF, open the Manager and choose
# Reports -> System Info and then click the phpinfo() link. Do a Find on Page
# for "register_globals". The Local Value should be OFF. If the Master Value
# is OFF then you do not need this directive here.
#
# IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :
#
# Your server does not allow PHP directives to be set via .htaccess. In that
# case you must make this change in your php.ini file instead. If you are
# using a commercial web host, contact the administrators for assistance in
# doing this. Not all servers allow local php.ini files, and they should
# include all PHP configurations (not just this one), or you will effectively
# reset everything to PHP defaults. Consult www.php.net for more detailed
# information about setting PHP directives.
#php_flag register_globals Off
# For servers that support output compression, you should pick up a bit of
# speed by un-commenting the following lines.
#php_flag zlib.output_compression On
#php_value zlib.output_compression_level 5
# The following directives stop screen flicker in IE on CSS rollovers. If
# needed, un-comment the following rules. When they're in place, you may have
# to do a force-refresh in order to see changes in your designs.
#ExpiresActive On
#ExpiresByType image/gif A2592000
#ExpiresByType image/jpeg A2592000
#ExpiresByType image/png A2592000
#BrowserMatch "MSIE" brokenvary=1
#BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
#BrowserMatch "Opera" !brokenvary
#SetEnvIf brokenvary 1 force-no-vary
Oh my I am sorry, could you pls edit this code and put three single ticks, like this `, in the lines above and below your code, that will preserve the code
# MODX supports Friendly URLs via this .htaccess file. You must serve web
# pages via Apache with mod_rewrite to use this functionality, and you must
# change the file name from ht.access to .htaccess.
#
# Make sure RewriteBase points to the directory where you installed MODX.
# E.g., "/modx" if your installation is in a "modx" subdirectory.
#
# You may choose to make your URLs non-case-sensitive by adding a NC directive
# to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
RewriteEngine On
RewriteBase /
# Prevent dot directories (hidden directories like .git) to be exposed to the public
# Except for the .well-known directory used by LetsEncrypt a.o
RewriteRule "/\.|^\.(?!well-known/)" - [F]
# Rewrite www.example.com -> example.com -- used with SEO Strict URLs plugin
#RewriteCond %{HTTP_HOST} .
#RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
#RewriteRule (.*) http://aircaretechnology.co.uk/$1 [R=301,L]
#
# or for the opposite example.com -> www.example.com use the following
# DO NOT USE BOTH
#
#RewriteCond %{HTTP_HOST} !^$
#RewriteCond %{HTTP_HOST} !^www\. [NC]
#RewriteCond %{HTTP_HOST} (.+)$
#RewriteRule (.*) http://www.aircaretechnology.co.uk/$1 [R=301,L]
# Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent
# https://www.aircaretechnology.co.uk when your cert only allows https://aircaretechnology.co.uk
#RewriteCond %{SERVER_PORT} !^443
#RewriteRule (.*) https://aircaretechnology.co.uk/$1 [R=301,L]
# Redirect the manager to a specific domain - don't rename the ht.access file
# in the manager folder to use this this rule
#RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
#RewriteCond %{REQUEST_URI} ^/manager [NC]
#RewriteRule ^(.*)$ https://aircaretechnology.co.uk/$1 [R=301,L]
# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
# Make sure .htc files are served with the proper MIME type, which is critical
# for XP SP2. Un-comment if your host allows htaccess MIME type overrides.
#AddType text/x-component .htc
# If your server is not already configured as such, the following directive
# should be uncommented in order to set PHP's register_globals option to OFF.
# This closes a major security hole that is abused by most XSS (cross-site
# scripting) attacks. For more information: http://php.net/register_globals
#
# To verify that this option has been set to OFF, open the Manager and choose
# Reports -> System Info and then click the phpinfo() link. Do a Find on Page
# for "register_globals". The Local Value should be OFF. If the Master Value
# is OFF then you do not need this directive here.
#
# IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :
#
# Your server does not allow PHP directives to be set via .htaccess. In that
# case you must make this change in your php.ini file instead. If you are
# using a commercial web host, contact the administrators for assistance in
# doing this. Not all servers allow local php.ini files, and they should
# include all PHP configurations (not just this one), or you will effectively
# reset everything to PHP defaults. Consult www.php.net for more detailed
# information about setting PHP directives.
#php_flag register_globals Off
# For servers that support output compression, you should pick up a bit of
# speed by un-commenting the following lines.
#php_flag zlib.output_compression On
#php_value zlib.output_compression_level 5
# The following directives stop screen flicker in IE on CSS rollovers. If
# needed, un-comment the following rules. When they're in place, you may have
# to do a force-refresh in order to see changes in your designs.
#ExpiresActive On
#ExpiresByType image/gif A2592000
#ExpiresByType image/jpeg A2592000
#ExpiresByType image/png A2592000
#BrowserMatch "MSIE" brokenvary=1
#BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
#BrowserMatch "Opera" !brokenvary
#SetEnvIf brokenvary 1 force-no-vary
Ok and compare your system settings with the picture on this page
https://docs.modx.com/revolution/2.x/administering-your-site/using-friendly-urls
And what behavior are you getting? Page is loading but just no change in urls?
Pls remember to clear the cache and flush permissions as well when you are done.
I crossed checked my settings with the one in the picture and they both match. Iâve also cleared the cache and flushed permissions. The page will load but the url doesnât change and is still /index.php?id=21 for example.
Update 1: I have also discovered another ht.access file under /manager/min. Will this need removing or editing as I still have the .htaccess file that is located within /manager
Ok good, we are narrowing this down. It did occur to me that you might have been editing the wrong htaccess file, there seem to be several of them.
I think I can say with confidence that the edited htaccess file isnât in the right place. This is due to the fact that the page loads with the old url. Genius, I know
Just joking, but normally you would be getting errors or blank pages if there was a problem, once the settings are turned on. I could be wrong here though.
Ok so, on the server, there can be some different configurations. I have my htaccess in the public_html folder on my server. I believe thatâs the one that needs to be changed.
Where is the one youâve been changing? Remember to change out domain info when answering
What value does your friendly_urls
system setting have? From the looks of the site, assuming youâre using either the link tags ([[~123]]
) or menu building snippets that generate the URLs (e.g. Wayfinder/pdoMenu), friendly urls hasnât been enabled yet in MODX.
When you edit a resource from the manager, and use the View
button in the top right, what URL does that send you to? Does the resource have an Alias
, or is that empty?
Itâs on the public_html folder within a folder called Manager.
The second ht access file is location in the min folder
I am directed to this page http://cluster5.website-staging.uk/aircaretechnology.co.uk/products/airpur5.html.html which is a 404 error
That sounds like your configuration file (in core/config/config.inc.php
) may have some incorrect values, probably from the automated installation by the hoster, that would be a good idea to fix. In particular, it seems like $http_host
(about half-way through the file) might not be right. If you have multiple contexts (if you donât know what that is yet, you probably donât), it may also be in the context settings.
A http_host misconfiguration shouldnât really affect the front-end though, as MODX will automatically calculate it where possible.
The double .html
at the end is also odd. Perhaps your resource has airpur5.html
as alias, while the .html
part is already added by the content type automatically?
You need to edit the .htaccess in the root of the MODX installation; not the one in /manager/
, and not /manager/min/
either. So go up one directory. It just needs this for MODX to work (on Apache):
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Iâve added the .htaccess file to the root of the MODX installation and edited it to include
Iâve cleared the cache and itâs still not working. Now when I click on View Im getting this error.
Itâs working on this link now: https://www.aircaretechnology.co.uk/products/airpur5.html.html
To make sure the right links are generated, you should inspect the config file as I mentioned before.
Also please triple check the friendly_urls
system setting is enabled and that you havenât hardcoded the index.php?id=123
links in the menu and such.
Wrong configuration file. Like I said, the configuration file in core/config/config.inc.php
.
Also donât blankly post configuration files on a public forum (especially the one in core/config as it contains database credentials).
Which section do I need to modify as I have found the file?
Anything that doesnât look right.
The variables ending in _path
are probably fine, but the ones ending in _url
donât seem to be.
Look specifically for these two variables:
-
$modx_base_url
, around line 47. Should probably be$modx_base_url = '/';
-
$http_host
, around line 62. Should probably be$http_host = 'www.aircaretechnology.co.uk';
Clear the MODX cache after changing the configuration file to see the effect.