【发布时间】:2014-10-05 19:01:36
【问题描述】:
我问了this 问题并得到了很好的答案,只是我仍然不明白这是怎么发生的。也许有人可以解释这个过程以及每个标志的作用。
所以现在我有,
site.com/index.php?query1=this&query2=that&query3=those and i want this translated into
site.com/song/this/that/those
这是现有的代码。
Options -Indexes +FollowSymLinks
RewriteEngine On
DirectoryIndex index.php
#/////////////append www before all urls///////////////////////////
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
RewriteCond %{THE_REQUEST} \ /+index\.php\?u=([^&\ ]+)
RewriteRule ^ /%1? [L,R=301]
#/////////////song
#///////////////////remove index.php from url/////////////
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ )
RewriteRule ^ /%1 [R=301,L]
#////////////Convert 'u' Query String////////////
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)$ index.php?u=$1 [L]
【问题讨论】:
标签: .htaccess url mod-rewrite url-rewriting