User Tools

Site Tools


doc:plugins:prettyurls

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
doc:plugins:prettyurls [2020/04/15 19:51] – removed arviddoc:plugins:prettyurls [2024/04/01 14:11] (current) – created arvid
Line 1: Line 1:
 +===== PrettyURLs =====
 +==== Description ====
 +PrettyURL plugin turns standard URLs into SEO friendly URLs.
  
 +
 +
 +==== Handling ====
 +<WRAP right round tip 350px>
 +**Hint:**\\ Only web servers that are NCSA compatible, such as Apache, are familiar with the concept of .htaccess files.
 +</WRAP>
 +For this to work as expected for entries, the server configuration must be adjusted.
 +If the .htaccess file does not yet exist in the main FlatPress directory, the plugin helps you to create a suitable file.
 +
 +Open the main panel Plugins in the administration area. Then open the subpanel PrettyURLs.
 +In the editor window you can see the recommended content for the .htaccess file.
 +<code>
 +AddType application/x-httpd-php .php .htm .html
 +Options -Indexes
 +
 +<IfModule mod_rewrite.c>
 +RewriteEngine On
 +RewriteBase /flatpress-instance/
 +
 +RewriteRule ^\.htaccess$ - [F]
 +
 +RewriteCond %{REQUEST_FILENAME} !-f
 +RewriteCond %{REQUEST_FILENAME} !-d
 +RewriteRule . /flatpress-instance/index.php [L]
 +</IfModule>
 +</code>
 +
 +You only need to save this file.
 +
 +Done.
 +
 +If this does not work, have a look at the [[en:doc:basic:troubleshooting|Troubleshooting]].
 +
 +==== Advanced ====
 +
 +To make files with the extension .php (e.G. contact.php, search.php) also friendly accessible, paste the following code into the editor instead of the above code:
 +<code>
 +Options -Indexes
 +Options +MultiViews
 +Options +FollowSymLinks
 +AddType application/x-httpd-php .php .htm .html
 +
 +<IfModule mod_rewrite.c>
 +  RewriteEngine On
 +  
 +# Protects the .htacces file from external access, status code 403 "Forbidden" is output
 +  RewriteRule ^\.htaccess$ - [F]
 +
 +  RewriteBase /flatpress-instance/
 +
 +# Removing .php Extension and adding a trailing slash at the end
 +  RewriteCond %{REQUEST_FILENAME} !-f
 +  RewriteRule ^([^/]+)/$ $1.php
 +  RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
 +  RewriteCond %{REQUEST_FILENAME} !-f
 +  RewriteCond %{REQUEST_FILENAME} !-d
 +  RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
 +  RewriteRule (.*)$ /$1/ [R=301,L]
 +
 +# Remove the fp-content directory
 +  RewriteCond %{REQUEST_FILENAME} !-f
 +  RewriteCond %{REQUEST_FILENAME} !-d
 +  RewriteCond %{REQUEST_FILENAME} !-l
 +  RewriteRule ^images/(.*) /flatpress-instance/fp-content/images/$1 [L]
 +  RewriteRule ^attachs/(.*) /flatpress-instance/fp-content/attachs/$1 [L]
 +
 +# Redirect all other requests to index.php
 +  RewriteCond %{REQUEST_FILENAME} !-f
 +  RewriteCond %{REQUEST_FILENAME} !-d
 +  RewriteRule ^.*$ /flatpress-instance/index.php [L,QSA]
 +  
 +# Forwarding from http to https without consideration of the subdomain (www.)
 +  RewriteCond %{SERVER_PORT} !^443$
 +  RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
 +</IfModule>
 +</code>
 +
 +==== Important note ====
 +In order for the PrettyURLs plugin to write or modify the .htaccess file, it is necessary that the directory and file permissions for the .htaccess file are set (chmod 0776). 
 +
 +Please note that on apache+windows prettyurls will not work, because there is NO mod_rewrite support!
 +
 +==== Nginx ====
 +<WRAP right round tip 350px>
 +**Hint:**\\ [[https://www.putty.org/|PuTTY]] is an ingenious SSH and Telnet client for the Windows platform.
 +</WRAP>
 +When using the Nginx server software, a few settings must be added manually with administrative access to the nginx.conf file. These can be found by default in the directories ''/usr/local/nginx/conf'' or ''/etc/nginx'' or ''/usr/local/etc/nginx''.
 +
 +First activate one of the two modes in the PrettyURLs configuration:
 +
 +**(*) HTTP Get** - Example: /?u=/2011/01/01/hello-world/
 +
 +or
 +
 +**(*) Pretty** - Example: /2011/01/01/hello-world/
 +
 +Then add the following code to the nginx.conf file:
 +
 +<code apache>
 +# see https://stackoverflow.com/questions/72521825/convert-htaccess-to-nginx-directives
 +location /flatpress-instance {
 +  if (!-e $request_filename) {
 +    rewrite ^/(.+)$ /flatpress-instance/index.php?u=$1 last;
 +    break;
 +  }
 +
 +</code>
 +
 +⚠️ It has not yet been confirmed that this works 100% on a live system.
doc/plugins/prettyurls.1586973117.txt.gz · Last modified: 2020/04/15 19:51 by arvid

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki