WAMP 的 Apache mod_rewrite 问题 - 显示错误 404 未找到 - Joomla 1.5.14 与 SEF URL

发布于 2024-08-07 06:34:02 字数 2978 浏览 7 评论 0原文

我是 Joomla 和 WAMP 环境的新手。我正在使用 WAMP 环境:

  • Win Srv 2003 R2 (Std Ed) with SP2 和所有最近更新
  • Apache 2.2.9
  • PHP 5.2.6
  • Joomla 1.5.14

我想使用 Joomla SEF URL 启用 mod_rewrite 但它不能一起工作。

  • 如果我将“SEF URL”和“向 URL 添加后缀”设置为“是”,则可以。
    结果:/index.php/page.html

  • 如果我将“mod_rewrite”和“向 URL 添加后缀”设置为“是”,则不会给出任何错误(不确定它是否按这种方式工作)它应该或不)。
    结果:/index.php?option=com_content&view=article&id=3&Itemid=5

  • 如果我将“SEF URLs”和“mod_rewrite”设置为“是”,那么它会给我“ 404 未找到”错误。
    结果:未找到 |在此服务器上找不到请求的 URL /pagename

  • 如果我将“SEF URLs”+“mod_rewrite”+“向 URL 添加后缀”设置为“是”,那么它会给我“ 404 未找到”错误。
    结果:未找到 |在此服务器上找不到请求的 URL /pagename.html

我正在使用 Joomla 提供的默认 .htaccess 代码如下:

 

##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On


########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a  tag in URL
RewriteCond %{QUERY_STRING} (\|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

#  Uncomment following line if your webserver's URL
#  is not directly related to physical file paths.
#  Update Your Joomla! Directory (just / for root)

 RewriteBase /abc  
# /abc is a sub-directory of joomla install in htdocs

########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section



在 httpd.conf 中

  • 我有 < code>LoadModule rewrite_modulemodules/mod_rewrite.so active (uncommented #)
  • 它在 Apache 的 modules 文件夹中有 mod_rewrite.so

我不确定我还需要做什么才能使其发挥作用。我几乎检查了所有论坛的帖子和博客。然而没有任何帮助。

我也有 PHP_MAILER 问题,但这并不那么重要。我很感激你的帮助。如果您需要更多详细信息来解决此问题,请告诉我。

亲切的问候

DM

I am newbie to Joomla and WAMP environiment. I am using WAMP environment:

  • Win Srv 2003 R2 (Std Ed) with SP2 and all recent updates
  • Apache 2.2.9
  • PHP 5.2.6
  • Joomla 1.5.14

I want to enable mod_rewrite with Joomla SEF URL but it is not working together.

  • If I set 'SEF URLs' and 'Add suffix to URLs' as Yes it works.
    Result: /index.php/page.html

  • If I set 'mod_rewrite' and 'Add suffix to URLs' as Yes it doesn't give any error (not sure if it works the way it suppose to or not).
    Result: /index.php?option=com_content&view=article&id=3&Itemid=5

  • If I set 'SEF URLs' and 'mod_rewrite' as Yes than it give me "404 Not Found" error.
    Result: Not Found | The requested URL /pagename was not found on this server

  • If I set 'SEF URLs' + 'mod_rewrite' + 'Add suffix to URLs' as Yes than it gives me "404 Not Found" error.
    Result: Not Found | The requested URL /pagename.html was not found on this server

I am using the default .htaccess provided by Joomla the code is as follows:

 

##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks

#
#  mod_rewrite in use

RewriteEngine On


########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a  tag in URL
RewriteCond %{QUERY_STRING} (\|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits

#  Uncomment following line if your webserver's URL
#  is not directly related to physical file paths.
#  Update Your Joomla! Directory (just / for root)

 RewriteBase /abc  
# /abc is a sub-directory of joomla install in htdocs

########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section


In httpd.conf

  • I have LoadModule rewrite_module modules/mod_rewrite.so active (uncommented #)
  • It has mod_rewrite.so in Apache's modules folder.

I am not sure what else I need to do to make it work. I have checked almost all the forums' posts and blogs. However nothing is helping.

I also have PHP_MAILER issue but that is not as important as this is. I appreciate your help. Please let me know if you need more details to solve this problem.

Kind Regards

DM

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅唱ヾ落雨殇 2024-08-14 06:34:02

我找到了问题的答案:我在httpd.conf中添加了目录,但AllowOverride设置为None而不是All以允许.htaccess生效。

apache 需要使用AllowOverride All 才能使用.htaccess。代码看起来像这样:

<Directory "D:/Apache/htdocs/joomla">
    AllowOverride all
    Options None
    Order allow,deny
    Allow from all
</Directory>

除了上述更改之外,还需要有“ RewriteBase / ”
(设置为on,即取消注释RewriteBase /)

I found out the answer to my issue: I added the Directory in httpd.conf but AllowOverride was set to None instead of All to allow .htaccess to take effect.

AllowOverride All needs be to there for apache to work with .htaccess. The code would look something like:

<Directory "D:/Apache/htdocs/joomla">
    AllowOverride all
    Options None
    Order allow,deny
    Allow from all
</Directory>

Along with above change one need to have " RewriteBase / "
(set to on, i.e.uncomment RewriteBase /)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文