簡體   English   中英

.htaccess幫助縮短網址

[英].htaccess help shortening a url

我一直在嘗試使用codeigniter設置網址縮短器,我的所有工作都很好,並且現在可以使用如下所示的縮短的網址。

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

好的,我只是想通過.htaccess訪問將其縮短為i,我是.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>

上面的代碼點火器與我的工具無關。 好的,請縮短我的控制器,我有一個名為i的函數,

我已經嘗試了各種組合,但對我沒有任何幫助,但是下面是我的.htaccess。

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> 

目前有什么正在打破該網站,只是看着和谷歌在mo,但我也想在這里添加一個帖子,謝謝

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

在數組中嘗試以下路由設置:

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

如果您對此有任何疑問,請告訴我。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM