Jump to content
ce90

URL rewrite to .php

Recommended Posts

Hello everyone,

hopefully this is the right place to ask and is not a duplicate question.

I'm pretty new to processwire, so...¬†if this question is kind of funny for some of you, you're welcome¬†ūüėĄ¬†
I have the following issue and can't find anything understandable about it. Maybe I'm searching the wrong way, but anyways.. here is my question:

How is it possible to rewrite the URLs, that I'll get a *.php ending?

Example:
https://www.mysite.de/urlsegment/ -> https://www.mysite.de/urlsegment.php
https://www.mysite.de/urlsegment/urlsegment/ -> https://www.mysite.de/urlsegment/urlsegment.php

Because I've read a lot about "Why do you wanna do this or have¬†that?" ‚Äď here my answer for that in advance:
I've built a processwire installation inside or around an existing website. Therefore, we want to keep the existing *.php Google entries. Sure, we could redirect via 301 Redirect, but would prefer to keep the *.php ending.

If you have further questions, please do not hesitate to ask.

Thank you in advance for your help.

‚Äď

Best regards
ce90

  • Like 1

Share this post


Link to post
Share on other sites

That would most likely be done in the .htaccess file.

But understand that when ProcessWire updates itself, it might/will over-write your .htaccess file.

Share this post


Link to post
Share on other sites
2 hours ago, ce90 said:

How is it possible to rewrite the URLs, that I'll get a *.php ending?

Have you tried this:

https://processwire.com/talk/topic/45-url-schema/?do=findComment&comment=150

"ProcessWire will support .html extensions. You just have to make them your page names, i.e. "about.html" rather than "about", or look for them in urlSegments. I've actually done this before, though for specific pages (like /sitemap.xml), not on a site-wide basis. But I don't see any problem with it  conceptually."

  • Like 5

Share this post


Link to post
Share on other sites

Hi @ce90 and welcome to the forum!

3 hours ago, ce90 said:

I've built a processwire installation inside or around an existing website. Therefore, we want to keep the existing *.php Google entries. Sure, we could redirect via 301 Redirect, but would prefer to keep the *.php ending.

I'd be happy to hear more about your setup to get a better context¬†ūüôā¬†

Share this post


Link to post
Share on other sites

As @szabesz mentioned, why not simply add the .php to the page name and disable "Should page URLs end with a slash?" in the template? Just tried, works well. You may even have a /index.php...

  • Like 8
  • Thanks 1

Share this post


Link to post
Share on other sites

@Autofahrn¬†& @szabesz¬†thank guys! This works like a charm! ‚̧ԳŹ

Didn't even know about that possibility ūüėĄ¬†In¬†my opinion? This is the¬†way to do it!

Thanks again.. I appreciate it!

  • Like 2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By daniel_puehringer
      Hi Community,

      Sadly I cannot intall ProcessWire on my webserver (Hosted at https://www.world4you.com/de/startseite.html, a small hosting provider in Austria)
      Here is the Problem: 
      1. I downloaded the current masterbranch as a .zip file (After a few tries I also downloaded the code via the git clone command, that led to the same error), unzipped it and transferred it to my server. Since there is already a wordpress site installed on the root directory, I transferred the processwire files into /relaunch and created a subdomain.
      2. I tried to install the language starter kit. As soon as I navigate to that folder Screenshot1 (see attached file 'processWireBug1') is shown. Everything looks nice, except the red text referring to the 'mod_rewrite' rule. The webserver provides the 'apache mod_rewrite' rule.
      3. As soon as I want to press 'Check again' or 'Continue to next step' an error Page with 500 error (see Screenshot 'processWireBug2') occurs.
      4. You can find my .htaccess file attached to this post..htaccess

      How could I solve this issue?

      Some additional information:
      1) the webserver provides the apache mod_rewrite (I checked that several times) and has php version 7.3. installed.
      2) since there is a wordpress site installed on the root directory, there is also a .htaccess file on the root directory. Could this .htaccess file have an impact on the .htaccess file for my processwire website?

      Thanks for your help and greetings from Austria,
      Daniel


    • By horst
      Hi, on a site I want to disable access to original images and only allow to access thumbnails and watermarked image variations.
      EDIT:
      A good solution for protecting original images can be found a bit down in this thread:
       
      Old content of this initial post:
       
    • By Peter Knight
      Hi all
      My .htaccess file is correctly redirecting all requests to
      https:// www. That's great until I want to work locally.
      I thought I had seen a blog post by Ryan where there was a new config setting to ignore both of these if working from localhost?
      I can't find it now so wondering if I was imagining ūüėē
       
       
    • By Robin S
      A new module that hasn't had a lot of testing yet. Please do your own testing before deploying on any production website.
      Custom Paths
      Allows any page to have a custom path/URL.
      Screenshot

      Usage
      The module creates a field named custom_path on install. Add the custom_path field to the template of any page you want to set a custom path for. Whatever path is entered into this field determines the path and URL of the page ($page->path and $page->url). Page numbers and URL segments are supported if these are enabled for the template, and previous custom paths are managed by PagePathHistory if that module is installed.
      The custom_path field appears on the Settings tab in Page Edit by default but there is an option in the module configuration to disable this if you want to position the field among the other template fields.
      If the custom_path field is populated for a page it should be a path that is relative to the site root and that starts with a forward slash. The module prevents the same custom path being set for more than one page.
      The custom_path value takes precedence over any ProcessWire path. You can even override the Home page by setting a custom path of "/" for a page.
      It is highly recommended to set access controls on the custom_path field so that only privileged roles can edit it: superuser-only is recommended.
      It is up to the user to set and maintain suitable custom paths for any pages where the module is in use. Make sure your custom paths are compatible with ProcessWire's $config and .htaccess settings, and if you are basing the custom path on the names of parent pages you will probably want to have a strategy for updating custom paths if parent pages are renamed or moved.
      Example hooks to Pages::saveReady
      You might want to use a Pages::saveReady hook to automatically set the custom path for some pages. Below are a couple of examples.
      1. In this example the start of the custom path is fixed but the end of the path will update dynamically according to the name of the page:
      $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'my_template') { $page->custom_path = "/some-custom/path-segments/$page->name/"; } }); 2. The Custom Paths module adds a new Page::realPath method/property that can be used to get the "real" ProcessWire path to a page that might have a custom path set. In this example the custom path for news items is derived from the real ProcessWire path but a parent named "news-items" is removed:
      $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'news_item') { $page->custom_path = str_replace('/news-items/', '/', $page->realPath); } }); Caveats
      The custom paths will be used automatically for links created in CKEditor fields, but if you have the "link abstraction" option enabled for CKEditor fields (Details > Markup/HTML (Content Type) > HTML Options) then you will see notices from MarkupQA warning you that it is unable to resolve the links.
      Installation
      Install the Custom Paths module.
      Uninstallation
      The custom_path field is not automatically deleted when the module is uninstalled. You can delete it manually if the field is no longer needed.
       
      https://github.com/Toutouwai/CustomPaths
      https://modules.processwire.com/modules/custom-paths/
    • By AndZyk
      Hello,
      I am currently building a intranet which will be hosted on the local network of a company. This intranet has many links to files on their fileserver with the protocol file://.
      So for example the links look like this file://domain.tld/filename.ext
      When I try to insert such a link into a URL field, I get the error, that only the protocol http:// is allowed. When I try to insert such a link into a CKEeditor link, it gets stripped out. Is it possible to insert such links into the FieldType URL and CKEditor.
      I know that I could use a FieldType Text or insert a RewriteRule in the .htaccess file, but I am looking for a more elegant solution.¬†ūüėČ
      Regards, Andreas
√ó
√ó
  • Create New...