我最近从代码峡谷购买了一个脚本,该脚本似乎可以在实时服务器上正常运行,但不能在WAMP(Apache Version:2.2.22)上运行,该脚本的要求是应该启用mod-rewrite,并且似乎已启用
在wamp的www文件夹中,我的代码驻留在名为的文件夹内jobs
,这就是我访问它的方式,http://localhost/jobs
但是每次它将我重定向到时http://localhost/jobs/US/
,我看到的只是WAMP Server Configuration Screen。
在实时服务器上,这.htaccess
看起来像
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^careers.clickteck.com
RewriteRule ^(.*)$ http://www.careers.clickteck.com/$1 [R=permanent,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我没有做.htaccess
那么多的事情,所以我不确定如何使脚本在localhost上工作,我确实尝试将RewriteBase
from更改为RewriteBase /
,RewriteBase /jobs
但是那也不起作用。
我什么都看不到apache error log
,但是我看到了apache access log
127.0.0.1 - - [25/Jul/2014:22:32:41 +0500] "GET /jobs/ HTTP/1.1" 302 -
127.0.0.1 - - [25/Jul/2014:22:32:42 +0500] "GET /jobs/US/ HTTP/1.1" 200 5924
127.0.0.1 - - [25/Jul/2014:22:32:43 +0500] "GET /jobs/US/index.php?img=pngFolder HTTP/1.1" 200 850
127.0.0.1 - - [25/Jul/2014:22:32:43 +0500] "GET /jobs/US/index.php?img=gifLogo HTTP/1.1" 200 4549
127.0.0.1 - - [25/Jul/2014:22:32:43 +0500] "GET /jobs/US/index.php?img=pngWrench HTTP/1.1" 200 741
127.0.0.1 - - [25/Jul/2014:22:32:43 +0500] "GET /jobs/US/index.php?img=pngPlugin HTTP/1.1" 200 548
127.0.0.1 - - [25/Jul/2014:22:32:43 +0500] "GET /jobs/US/index.php?img=pngFolderGo HTTP/1.1" 200 694
如果有人能告诉我我在做什么错或如何使其在localhost上运行,我将非常感谢。
解
我进行了以下更改以.htaccess
解决问题
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
---> RewriteRule . jobs/index.php [L] <----
</IfModule>
我通过研究.htaccess
localhost上的wordpress文件使其工作,并得出了一个解决方案,因为脚本位于一个名为的文件夹中,jobs
所以我也需要.htaccess
通过执行此操作将其添加到文件中RewriteRule . jobs/index.php [L]
。
这是完整的.htaccess
代码
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . jobs/index.php [L]
</IfModule>
这解决了我的问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句