dongqie2028
dongqie2028
2013-06-19 01:28

CodeIgniter URL mod_rewrite

已采纳

I am trying to study codeigniter. I am confused with URL mod_rewrite. I use 2 pages: home.php and about.php in view directory, and call them using controller Site. In both the pages i gave links for it with controller functions home, about respectively:

< a href='home'>Home</a>
< a href='about'>About</a>

when I type the URL as localhost/Project/Site/home and localhost/Project/Site/about it works efficiently. My problem is when I call the URL "localhost/Project" I can get the home.php but after that if I click on any links (Home / About ), the url will be localhost/Project/home and can not access the page.

I am using .htaccess as the direction in the YouTube video

It may be a simple issue but i can't solve it. Please help me.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • duanbei6427 duanbei6427 8年前

    prepending the path with a slash will make it link from your root url

    I would just give it the path that works, something like:

    < a href='/Project/site/home'>Home</a> < a href='/Project/site/about'>About</a>

    right now it appends to the current url, as you see what is happening

    点赞 评论 复制链接分享

为你推荐