WAMP 的 Apache mod_rewrite 问题 - 显示错误 404 Not found - Joomla 1.5.14 with SEF URL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1568246/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apache mod_rewrite issue with WAMP - shows Error 404 Not found - Joomla 1.5.14 with SEF URL
提问by DM.
I am newbie to Joomla and WAMP environiment. I am using WAMP environment:
我是 Joomla 和 WAMP 环境的新手。我正在使用 WAMP 环境:
- Win Srv 2003 R2 (Std Ed) with SP2 and all recent updates
- Apache 2.2.9
- PHP 5.2.6
- Joomla 1.5.14
- 使用 SP2 和所有最新更新赢得 Srv 2003 R2 (Std Ed)
- 阿帕奇 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.
我想使用 Joomla SEF URL 启用 mod_rewrite 但它不能一起工作。
If I set 'SEF URLs' and 'Add suffix to URLs' as Yes it works.
Result:/index.php/page.htmlIf 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=5If I set 'SEF URLs' and 'mod_rewrite' as Yes than it give me "404 Not Found" error.
Result: Not Found | The requested URL/pagenamewas not found on this serverIf 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.htmlwas not found on this server
如果我将 'SEF URLs' 和 'Add suffix to URLs' 设置为 Yes 就可以了。
结果:/index.php/page.html如果我将 'mod_rewrite' 和 'Add suffix to URLs' 设置为 Yes,它不会给出任何错误(不确定它是否像它假设的那样工作)。
结果:/index.php?option=com_content&view=article&id=3&Itemid=5如果我将“SEF URLs”和“mod_rewrite”设置为“是”,那么它会给我“404 Not Found”错误。
结果:未找到 |/pagename在此服务器上找不到请求的 URL如果我将 'SEF URLs' + 'mod_rewrite' + 'Add suffix to URLs' 设置为 Yes,那么它会给我“404 Not Found”错误。
结果:未找到 |/pagename.html在此服务器上找不到请求的 URL
I am using the default .htaccess provided by Joomla the code is as follows:
我使用的是 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
In httpd.conf
在 httpd.conf 中
- I have
LoadModule rewrite_module modules/mod_rewrite.soactive (uncommented#) - It has mod_rewrite.soin Apache's modulesfolder.
- 我有
LoadModule rewrite_module modules/mod_rewrite.so活动(未注释#) - 它在 Apache 的模块文件夹中有mod_rewrite.so。
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.
我也有 PHP_MAILER 问题,但这并不重要。我感谢您的帮助。如果您需要更多详细信息来解决此问题,请告诉我。
Kind Regards
亲切的问候
DM
DM
回答by DM.
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.
我找到了我的问题的答案:我在 httpd.conf 中添加了目录,但 AllowOverride 设置为 None 而不是 All 以允许 .htaccess 生效。
AllowOverride All needs be to there for apache to work with .htaccess. The code would look something like:
AllowOverride All 需要在那里让 apache 与 .htaccess 一起工作。代码如下所示:
<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 /)
随着上面的改变,需要有“RewriteBase/”
(设置为on,ieuncomment RewriteBase/)

