0
votes

i have been working on setting up a url shortener with codeigniter i have everything working great and it works now with shortened urls like below.

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

ok what am looking to do is shorten it just to the i with my .htaccess access i am a complete newbie with .htaccess and have no idea how to do this is have been following this example here. http://briancray.com/posts/free-php-url-shortener-script/

which uses

<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>

Above is not really relevant for mine as its code igniter based. ok so shorten is my controller and i have a function within called i,

i have tried various combinations but nothing has worked for me yet below is my .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> 

whats there is currently breaking the website at the moment just looking and google at the mo but thought i would also add a post here as well thanks

1

1 Answers

0
votes

With CI (or any framework for that matter), it is best to never touch the .htaccess file, unless you really need to. Take a look at the documentation with regard to working with the routes.php file in your application/config directory.

Try this route setting in the array:

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

Please let me know if you have any problems with this.