Mod_rewite和URL重定向 - APACHE,Mod_rewrite,PHP,Codeigniter [英] Mod_rewite and URL redirection - APACHE,Mod_rewrite,PHP,Codeigniter

查看:313
本文介绍了Mod_rewite和URL重定向 - APACHE,Mod_rewrite,PHP,Codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常具体的问题。我使用wamp服务器在本地运行我的codeigniter项目。我已经加载了mod_rewrite,它显示在我的phpinfo。

I have got a very specific problem. I am using wamp server to run my codeigniter projects locally. I have loaded mod_rewrite in and it is showing in my phpinfo.

在我的wamp根目录,我有一个codeigniter项目文件夹mysite。这是目录结构mysite。

In my wamp root directory, I have a codeigniter project folder "mysite".Here is the directory structure of mysite.

-mysite
   |--images
   |--eshots
   |--useruploads
   |--temp
   |--SpryAssets
   |--css
   |--js
   |--timthumb

启用此mod_rewrite之后,我在我的Windows目录中修改了我的主机文件,并在虚拟主机文件中添加了这行代码我的网站这样。 (mysite.local)

After enabling this mod_rewrite, I modified my "host" file in my windows directory and added this line of code in my virtual host file to access my website like this. (mysite.local)

   127.0.0.1 mysite.local

之后,我在根目录下创建了一个htaccess文件(即在mysite文件夹下)

After this I created an htaccess file in root directory (i.e under mysite folder)

  htaccess file:

  RewriteEngine on

  RewriteCond $1  !^(index\.php|images|lists|eshots|useruploads|temp|SpryAssets|css|js|robots\.txt|timthumb\.php)

  RewriteRule ^(.*)$ /index.php?$1 [L]

  <IfModule mod_security.c>

  SecFilterEngine Off

  SecFilterScanPOST Off

  </IfModule>

之后,当我尝试从wamp访问我的网站时,例如,如果我点击localhost的项目文件夹ie mysite,它回到localhost文件夹,我的URL看起来像这样:

After this, when I try to access my website from the wamp, it leads me to nowhere. For example, if I click from localhost's project folder i.e mysite, it takes me back to the localhost folder and my URL looks like this:

http://mysite.local/mysite/

,当我点击mysite再次,它显示的URL如下:

and when I click on mysite again, it shows the URL like this:

http:/ /mysite.local/mysite/mysite

然后,我的链接不会带我到网页。并保持在这里。
为什么我从服务器得到这种行为? CODEIGNITER或htaccess文件是否有任何问题,停止这个?我需要做什么步骤,以便我可以得到每个N的一切工作,包括javascript,css,图像。

And after this, my link doesn't take me to the web pages. And remain stuck here. Why am I getting this behavior from server? Is there any problem with CODEIGNITER or htaccess file that is stopping this? And what steps I need to do so that I could get each N everything working including javascript, css, images .

KINDLY建议我处理这个挑战性问题! NONE COULD HELP ME
大多数人说你需要启用你的mod_rewrite或从Apache提供的阅读手册。

KINDLY ADVISE ME TO DEAL WITH THIS CHALLENGING PROBLEM! NONE COULD HELP ME. Mostly people say you need to have your mod_rewrite enabled or read manual provided from Apache.

[UPDATED]:
当我TRIED WID新的代码指示器project.FIRST,我将所有的文件从htaccess文件复制到项目文件夹。幸运的是我能够导航到索引页,但它没有显示任何CSS,图像,脚本。
我的htaccess只包括这些位:RewriteEngine on。

[UPDATED]: when I TRIED WID new codeigniter project.FIRST,I copied all the files apart from htaccess file into project folder.Luckily i was able to navigate to the index page but it didnt show me any css,image,scripts. My htaccess consists of only these bits: RewriteEngine on .

现在我应该怎么做我的js,图像工作如上?Apache_error日志看起来像这样:。此外,当我尝试移动到下一页,它说(错误:404)请求的URL /Code/wham.local/categories/listings/Products没有找到。建议.what.local是虚拟的主机。

What shall i do now to make my js,images work as above?Apache_error log looks like this:.Also,when i try to move onto next pages ,it says "(Error:404)The requested URL /Code/wham.local/categories/listings/Products was not found".Kindly suggest.Where wham.local is virtual host.

apache_error日志

 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/css, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/css, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/js, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/js, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/js, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/js, referer: http://localhost/Code/

 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/js, referer: http://localhost/Code/

 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/images, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/images, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/images, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/images, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/images, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/images, referer: http://localhost/Code/
 [Sun Nov 25 13:00:54 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/images
 [Sun Nov 25 13:01:03 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/images
 [Sun Nov 25 13:01:55 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/images
 [Sun Nov 25 13:01:56 2012] [error] [client 127.0.0.1] File does not exist: D:/wamp/www/Code/wham.local, referer: http://localhost/Code/


推荐答案

检查C:\wamp\bin\apache\\中的http.conf文件\\Apache2.2.17\conf
如果他们是这样的条目
#Virtual hosts
#Include conf / extra / httpd-vhosts.conf
然后打开文件httpd-vhosts .conf中添加以下行。

check the http.conf file in C:\wamp\bin\apache\Apache2.2.17\conf if their is entry like this #Virtual hosts #Include conf/extra/httpd-vhosts.conf then open the file httpd-vhosts.conf add below lines in it.

     <VirtualHost *:80>
       DocumentRoot  "C:/wamp/www/mysite/"
       ServerName     mysite.local
      </VirtualHost>

     <VirtualHost *:80>
      DocumentRoot  "C:/wamp/www/"
      ServerName     localhost
      </VirtualHost>

否则可以将此行添加到httpd.conf文件
并重新启动ur server。
这是虚拟主机的概念。

otherwise you can add this line to httpd.conf file also and restart ur server. this is the virtual host concept.

这篇关于Mod_rewite和URL重定向 - APACHE,Mod_rewrite,PHP,Codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆