2013-02-20 191 views
0

這裏的htaccess重寫規則是我的.htaccess:的個人資料網址

RewriteEngine on 
RewriteBase /site 
RewriteCond %{request_filename} -f 

RewriteRule ^(.*) $1 [L] 
RewriteRule ^([a-z]+)(/([^/]{0,32})(/.+)?)?$ index.php?a=$1&u=$3 [L] 

我想有這樣 短網址,如果有人去www.mysite.com/johndoe htaccess的送他/她這個link index.php?a = profile & u = johndoe 要做到這一點,最好的方法是什麼?我看過htaccess的教​​程,並嘗試不同的方法和失敗:/

+0

是否所有的URL對個人資料的鏈接?如果是,那麼我可以修正這個規則。如果沒有(即你有'about-us'和'blog'),那麼你的'htaccess'方法將不適用,因爲可能存在衝突。 – 2013-02-20 05:20:57

+0

@MikeAnthony是啊還有其他的規則,所以我相信exeptions必須作出 – cppit 2013-02-20 11:33:02

回答

-1

嘗試反轉的條件,並刪除重寫基地:

RewriteEngine on 

RewriteCond %{request_filename} !-f 
RewriteCond %{request_filename} !-d 
RewriteRule ^([^/]+)/?$ /index.php?a=profile&u=$1 [L] 

這將使這樣:

如果有人去www.mysite.com/johndoe

的 「人johndoe」 得到由^([^/]+)/?$匹配,採用$1河反向引用?在esulting:

該鏈接的index.php A =輪廓& U = johndoe的

+0

刪除重寫基地?井位於/ site文件夾下。和頁面通過/ pagename訪問。 – cppit 2013-02-20 11:38:04

+0

@fogsy但根據你的問題,你的URL如下所示:'www.mysite.com/johndoe'。而且根據你的問題,你希望它被重寫爲'index.php?a = profile&u = johndoe',我沒有看到它說'/site/index.php?a = profile&u = johndoe'。 – 2013-02-20 17:46:17

+0

對此感到抱歉。它需要是/ site/name。如果我將這些文件移動到/然後它應該只是/只有名字...它有道理嗎? – cppit 2013-02-21 03:23:14

相關問題