douan1893 2016-01-08 11:54
浏览 55
已采纳

PHP Seo友好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.

  • 写回答

3条回答 默认 最新

  • doukong1391 2016-01-08 12:15
    关注
    RewriteCond %{REQUEST_URI} ^download/(.*)$ [NC]
    RewriteRule ^(.*)$ index.php?down=$1 [L,QSA]
    

    to catch filename in index.php:

    $filename = $_GET["down"];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?