I am using CodeIgniter for my web app and i want to avoid on keep using base_url() function in all my urls in the views.
Now this code is what i want :
<a href="/user/create">Click me to create user</a>
instead of
<a href="<?php echo base_url(); ?>user/create">Click me to create user</a>
However, specifying "/user/create" will redirect me to below url which is incorrect
http://localhost/user/create
What i want is that "/user/create" url in href should automatically redirect me to
http://localhost/myapp/user/create
without specifying base_url()
Is this possible?
This is my current .htaccess file
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /myapp/
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|images)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
Any help would greatly be appreciated.
Thanks