PHP Seo Friendly URL
I'm having some trouble using rewrite engine to achieve my goal with friendly url.
Basically I have the following structure: - index.php - down - index.php
My links in main index are something like this: download/index.php?down=FILENAME
I would like it to rewrite something like /download/FILE-NAME ( while pointing for the index.php inside download folder ). I would like my links in first index could be used as well /download/FILE-NAME
My actual code:
RewriteEngine On
RewriteRule download/^([a-zA-Z0-9_-]+)$ index.php?down=$1
Can anyone help me achieving this? I'm constantly getting error due to I can't do it right. After that, how can I get the the variable $1 after transform to seo friendly urls? I will have download/FILE-NAME and I need with PHP get the info from FILE-NAME.
So basically in the main index.php I would have a link like /download/FILE-NAME that will open the down/index.php file with the FILE-NAME ( staying something like.
Answer
RewriteCond %{REQUEST_URI} ^download/(.*)$ [NC]
RewriteRule ^(.*)$ index.php?down=$1 [L,QSA]
to catch filename in index.php:
$filename = $_GET["down"];
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?