Ad

PHP Seo Friendly URL

- 1 answer

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.

Ad

Answer

RewriteCond %{REQUEST_URI} ^download/(.*)$ [NC]
RewriteRule ^(.*)$ index.php?down=$1 [L,QSA]

to catch filename in index.php:

$filename = $_GET["down"];
Ad
source: stackoverflow.com
Ad