This topic is locked

2018 - Search Engine Friendly URL's htaccess

3/19/2018 4:22:47 PM
PHPRunner General questions
S
skbrasil author

How to use friendly urls with phprunner, manipulating with htacces, in my test I was able to run 100% on a localhost, xammp server and on an online server with the serverpilot.io control panel on digitalocean.com, in a virtual private machine.
One of the great barriers we encounter with phprunner is how to manipulate urls, for example to create a blog, after many tests finally manage to handle working perfectly, of course you will have to make some adjustments according to your project.
Apache .htaccess Example

Options +FollowSymlinks
# Prevent Directoy listing

Options -Indexes
# Prevent Direct Access to files

<FilesMatch "\.(tpl|ini|log)">

Order deny,allow

Deny from all

</FilesMatch>
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d
#Manipulate the search page
RewriteRule ^search.php$ blog_list.php?qs=$1 [L,QSA,NC]
#Manipulate the search page end
#Manipulate the blog page
RewriteRule ^blog/([a-zA-Z0-9_-]+)/(.*)/?$ blog_view.php?editid1=$1&slug=$2
#Manipulate the blog page end


One of the secrets is concatenate or create a field in the tables to generate the slug, in my case I used the sql concat to manipulate the slug, but if you are expert and able to manipulate via php code directly in phprunner, stay free to share with us.



Example of the concatenated line in sql query:

concat(lcase(replace(`post_id`.`idPost`,' ','-')), '/', lcase(replace(`post_name`.`Title`,' ','-')), '-', lcase(replace(`post_category`.`Category`,' ','-')), '-', lcase(replace(`manuals_type`.`post_type`,' ','-')), '.html') AS postSlug,


Note that in addition to converting to smaller words, I added .htm, but it works perfectly without .html