我一直在努力使用 codeigniter 设置一个 url 缩短器,我的一切工作都很好,它现在适用于如下所示的缩短 URL。
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'
如果您对此有任何问题,请告诉我。