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

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

问题描述

我有一个非常具体的疑难问题。我使用瓦帕服务器来运行locally.I在已加载的mod_rewrite我的codeigniter项目,它显示在我的phpinfo。

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

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

启用这个了mod_rewrite之后,我修改了主人的文件在我的windows目录下,并在我的虚拟主机文件中添加此行的code来访问我的网站,像这样的。 (mysite.local)

  127.0.0.1 mysite.local
 

在此我创建了根direcotry(即下的mysite文件夹)的htaccess文件

  htaccess文件:

  RewriteEngine叙述上

  的RewriteCond $ l ^(指数\ .PHP |图片|名单| eshots | useruploads |温度| SpryAssets | CSS | JS |机器人\ .TXT | timthumb \ .PHP)!

  重写规则^(。*)$ /index.php?$1 [L]

  < IfModule mod_security.c>

  SecFilterEngine关闭

  SecFilterScanPOST关闭

  < / IfModule>
 

在此,当我试图从WAMP访问我的网站,它使我nowhere.For例如,如果我从本地主机的项目文件夹中,即mysite的点击,它把我带回到本地主机文件夹,我的网址看起来像这样

HTTP://mysite.local/mysite/

,当我再次点击mysite的,它显示的网址是这样的:

HTTP://mysite.local/mysite/mysite

和在此之后,我的链接犯规带我到网上pages.And这里仍然停留。 有谁能够纠正我,为什么我收到此行为与服务器?是否与codeIGNITER或正在停止此htaccess文件的任何问题???什么步骤我需要做的,这样我可以得到每个n一切工作包括JavaScript,CSS,图片。

好心劝我来处理这个具有挑战性的问题!没有人能帮助我。 大多人说,你需要有你的mod_rewrite启用或读取Apache的。我提供所做的一切手册,但还是我被困超过2个星期继续进行。!!

[增订]: 当我试图WID新的codeigniter project.FIRST,我复制所有文件,除了从htaccess文件到项目folder.Luckily我是能够导航到该索引页,但它并没有给我任何的CSS,图像,脚本。 我的htaccess的只包含这些位:RewriteEngine叙述上

我拿什么现在怎么做才能让我的JS,图像按上述方式工作Apache_error日志如下:?。还有,当我尝试移动到下一个页面,它说:(错误:404)所请求的网址/ code / wham.local /分类/目录/产品未找到.Kindly suggest.Where wham.local是虚拟主机。

apache_error日志:

  [太阳11月25日13点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW / CSS,引用者:HTTP: //本地主机/ code /
 [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW / CSS,引用者:HTTP://本地主机/ code /
 [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW / JS,引用者:HTTP://本地主机/ code /
 [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW / JS,引用者:HTTP://本地主机/ code /
 [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW / JS,引用者:HTTP://本地主机/ code /
 [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW / JS,引用者:HTTP://本地主机/ code /

  [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW / JS,引用者:HTTP://本地主机/ code /

  [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW /图片,引用者:HTTP://本地主机/ code /
  [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW /图片,引用者:HTTP://本地主机/ code /
  [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW /图片,引用者:HTTP://本地主机/ code /
  [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW /图片,引用者:HTTP://本地主机/ code /
   [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW /图片,引用者:HTTP://本地主机/ code /
   [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW /图片,引用者:HTTP://本地主机/ code /
   [太阳11月25日十三点00分54秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW /图片
   [太阳11月25日十三点01分03秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW /图片
   [太阳11月25日十三时01分55秒2012] [错误] [客户127.0.0.1]文件不存在:D:/ WAMP / WWW /图片
   [太阳11月25日13:01:56 2012] [错误] [客户127.0.0.1]文件不存在:D:/wamp/www/$c$c/wham.local,引用者:HTTP://本地主机/ code /
 

解决方案

检查在C http.conf文件:\瓦帕\ BIN \ apache的\ Apache2.2.17 \的conf 如果他们是喜欢这篇日志         #Virtual主机         #INCLUDE的conf /加/的httpd-vhosts.conf         然后打开该文件的httpd-vhosts.conf添加以下线路在里面。

 <虚拟主机*:80>
       的DocumentRootC:/ WAMP / WWW / mysite的/
       服务器名mysite.local
      < /虚拟主机>

     <虚拟主机*:80>
      的DocumentRootC:/ WAMP / WWW /
      服务器名本地主机
      < /虚拟主机>
 

否则,你可以加入这行到httpd.conf文件还 并重新启动UR服务器。 这是虚拟主机概念

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.

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

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

After this i created an htaccess file in root direcotry (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>

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/

and when i click on mysite again ,it shows the url like this:

http://mysite.local/mysite/mysite

And after this,my link doesnt take me to the web pages.And remain stuck here. IS THERE ANYONE WHO COULD CORRECT ME WHY I AM 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 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 .I have done everything But still I AM STUCK FOR MORE than 2 weeks to proceed any further.!!

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

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

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

解决方案

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>

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天全站免登陆