Clean URLs settings

What do I need to do to be able to set up clean URLs?

Clean URLs for what exactly? Can you share any more information about how your site is hosted, what you’re trying to do, etc?

What’s an example of a non-clean URL that you want to make into a “clean” URL?

You want to change the URL in the address bar of the user’s Web browser, or in the background, or something else? I’d suggest try to use Transform Rules or Cloudflare Worker, if so. Otherwise, using Page Rules → Forwarding Rule could help.

Nevertheless, due to my curiosity, may I ask what kind of app and/or Web server are you using that you cannot change the URL or route to some “nicer” URLs at the origin host/server/app itself? :thinking:

Yes, sorry, my post it’s too generic. This is the scenario to provide more details:

I’m hosting the website with InmotionHosting and using Moodle as the LMS. DNS is routed through Cloudflare. I contacted InmotionHosting to be able to solve this issue with clean URLs. They gave me an explanation that I didn’t understand about updating something on Cloudflare.

I’m using a plugin called static pages Moodle plugins directory: Static Pages in Moodle to create a static page, and I want to have a readable, clean URL instead of PHP?-node345… Actually, I want to have clean URLs through the website.

I added this rule into the .htaccess but it didn’t do anything:

RewriteEngine On
RewriteRule ^/static/(.*).html$ /local/staticpage/view.php?page=$1&%{QUERY_STRING} [L]

This is an screenshot from the plugin page.

Hi Fritex,

Thanks for your feedback. Not sure if that’s the right approach for what I’m trying to do.

I provided more context to the issue to understand the problem that I’m trying to solve.

Essentially you want to have visitors you enter this in the address bar:
https://example.com/static/someinterestingtitle.html?querystring=bar be served a file that actually exists at https://example.com/foo/view.php?page=someinterestingtitle&querystring=bar, and you don’t want users to see any of the view.php?page= stuff.

You can do this using Cloudflare Transform Rules. You can start with this blog post:

and the documentation here:

https://developers.cloudflare.com/rules/transform/url-rewrite/

1 Like

Thanks Michael, I will try your proposed solution.

I’m not sure what rule I should use to set up clean URLs. Unfortunately, the documentation doesn’t provide you with a guide on how to achieve that. Do you know what rule I should use?

Screenshot from Cloudflare transform rules settings:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.