2015-05-15 20 views
1

我需要的鏈接轉換在我的網站上這樣說:htaccess的mod_rewrite的,以example.com/tut/2

wwww.example.com/tut/1 

wwww.example.com/tut.php?v=1 

我試過很多方法,但沒有事情發生

我的代碼是這樣的

RewriteEngine On 
RewriteRule ^tut/(\d+) tut.php?v=$1 [QSA,L] 

是否有任何其他想法或代碼?

回答

2

可以在根的.htaccess使用此代碼:

Options -MultiViews 
RewriteEngine On 
RewriteBase/

RewriteCond %{THE_REQUEST} /tut\.php\?v=(\d+) [NC] 
RewriteRule^/tut/%1? [R=302,L,NE] 

RewriteRule ^tut/(\d+)/?$ tut.php?v=$1 [QSA,L,NC] 
+0

你是什麼意思根htaccess的? – badr

+0

即您的'DocumentRoot'文件夾中的'.htaccess'。 – anubhava

+0

它不起作用 – badr