Web アプリに CodeIgniter を使用していますが、ビュー内のすべての URL で base_url() 関数を使用し続けることを避けたいと考えています。
今、このコードは私が欲しいものです:
<a href="/user/create">Click me to create user</a>
それ以外の
<a href="<?php echo base_url(); ?>user/create">Click me to create user</a>
ただし、「/user/create」を指定すると、間違った以下の URL にリダイレクトされます
http://localhost/user/create
私が欲しいのは、href の「/user/create」URL が自動的に私をリダイレクトすることです
http://localhost/myapp/user/create
base_url() を指定せずに
これは可能ですか?
これは私の現在の .htaccess ファイルです
<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>
どんな助けでも大歓迎です。
ありがとう