2012-09-30 146 views
0

我一直在努力與codeigniter建立一個網址shortener我有一切工作很好,它現在與縮短的網址,如下所示。.htaccess幫助縮短網址

http://example.com/shorten/i/znAS

確定什麼我希望做的是它縮短只是用我的.htaccess訪問我我跟的.htaccess一個完整的新手,不知道怎麼做,這是已經在這裏下面這個例子。 http://briancray.com/posts/free-php-url-shortener-script/

它採用

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteRule ^shorten/(.*)$ shorten.php?longurl=$1 [L] 
RewriteRule ^([0-9a-zA-Z]{1,6})$ redirect.php?url=$1 [L] 
</IfModule> 

上面沒有爲我基於它的代碼點火器真正相關。好吧,縮短是我的控制器,我有一個函數內我叫012,

Options   +FollowSymLinks 
Options   -Indexes 
DirectoryIndex index.php 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^shorten/(.*)$ shorten/i/=$1 [L] 
#RewriteRule ^(.*)$ index.php/$1 [L] 
RewriteRule ^(.*)$ index.php?/$1 [L] 

<Files "index.php"> 
AcceptPathInfo On 
</Files> 

什麼也正在打破該網站目前只是在尋找,並在莫谷歌,但想到我也將增加一個職位在這裏也感謝

回答

0

隨着CI(或與此有關的任何框架) ,最好不要碰.htaccess文件,除非你真的需要。查看有關在application/config目錄中使用routes.php文件的文檔。

嘗試這條路線設置在陣列中:

'shorten/(.+)' => 'shorten/i/$1' 

請讓我知道,如果您有任何與此問題。