【问题标题】:In my Apache Server I can't seem to be getting mod_rewrite to work for some reason [closed]在我的 Apache 服务器中,由于某种原因,我似乎无法让 mod_rewrite 工作 [关闭]
【发布时间】:2012-10-01 04:52:31
【问题描述】:

已更新 - 更清楚地了解我遇到的 mod_rewrite 失败。在 Apache 中,我在配置文件中有以下设置:

  LoadModule rewrite_module modules/mod_rewrite.so

  DocumentRoot "C:/mywebdev/apache/www"
  RewriteEngine On
  Include conf/extra/httpd-vhosts.conf

  <Directory "C:/mywebdev/apache/www">
  Options Indexes FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from All
  </Directory>

我的虚拟主机配置中有以下内容

  <Directory "C:/mywebdev/apache/www/test">
  Options Indexes FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from All
  </Directory>

 <Directory "C:/mywebdev/apache/www/test/.htaccess">
  Options Indexes FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from All
  </Directory>

  NameVirtualHost *:80

  <VirtualHost *:80>
  DocumentRoot C:/mywebdev/apache/www/test
  ServerName www.test.me
  ServerAlias test.me *.test.me
  LoadModule rewrite_module modules/mod_rewrite.so
  <IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_URI} !^/library/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  </IfModule>
  </VirtualHost>

在 .htaccess 文件中我有这个:

  <IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_URI} !^/library/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  </IfModule>

我知道这有点矫枉过正,但这只是为了表明无论我做什么都不起作用。我检查了 mod_rewrite.so 是否在模块文件夹中并且它在那里。该模块不适用于此规则或我尝试使用的任何其他 mod_rewrite 规则。从我读过的内容来看,这应该可以工作。提前感谢您的帮助。

【问题讨论】:

  • 你得到了什么?
  • 检查更新的问题以了解新的细节。
  • 我没有发现任何不同...
  • @Praveen Kumar - 抱歉,我需要一些时间来更新它。

标签: php mod-rewrite apache2


【解决方案1】:

我不确定,但是,内容:

  RewriteEngine On
  RewriteCond %{REQUEST_URI} !^/library/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]

应该进入该文件夹中的.htaccess 文件。如果我错了,请纠正我。

【讨论】:

  • 我以为你可以直接把它放在 中。我相信 .htaccess 适用于您在公共服务器/共享服务器上上线时使用。
  • 老兄,它在您放置内容的文件夹中。该规则应该进入C:/mywebdev/apache/www/test/.htaccess
  • 我只是把它改成了: Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from All
  • 我仍然一无所获。我现在收到错误报告。请允许我用新的错误报告更新。
  • 已更新更清晰的问题减去缩小插件/设置。
【解决方案2】:

在这之间插入你的重写代码

<IfModule mod_rewrite.c>CODE</IfModule>

【讨论】:

  • 我刚做了这个。我将它放在 中,仍然没有任何错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-16
  • 2022-11-27
  • 2022-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-28
  • 1970-01-01
相关资源
最近更新 更多