mod_rewrite需要完成哪些初始设置?

时间:2012-01-14 19:51:42

标签: apache .htaccess mod-rewrite url-rewriting apache2

mod_rewrite需要完成哪些初始设置?

这是因为我无法找到合适的文章 我认为这个问题将被低估。

好的,为了避免被投票,

我尝试了这些设置,但mod_rewrite似乎不起作用:

LoadModule rewrite_module modules/mod_rewrite.so 

<Directory />
    Options -Indexes +FollowSymLinks
    RewriteEngine On
    AllowOverride All
</Directory>

<Directory "/mysite">
    Options -Indexes +FollowSymLinks
    AllowOverride All  # was suggested to do this from many sites.  
                       # So mod_rewrite could work
    Order allow,deny
    Allow from all
    RewriteEngine On
</Directory>


<VirtualHost 'ip-addr'>
    .
    .
    .
    Options -Indexes +FollowSymLinks
    RewriteEngine On
</VirtualHost>

httpd -t -D DUMP_MODULES | grep rewrite

有输出:

 rewrite_module (shared)
Syntax OK

我的DocumentRoot/mysite。 在xhprof中设置/mysite/xhprof

xhprof的index文件位于/mysite/xhprof/xhprof_html

/mysite/xhprof/xhprof_html/.htaccess

RewriteEngine On
RewriteBase   /xhprof

当我尝试访问<myurl>/xhprof/xhprof_html/时,网址不会被重写。

2 个答案:

答案 0 :(得分:0)

包括以下内容:

Options +FollowSymlinks
RewriteEngine on

此外,请确保在常规HTTP配置中({1}}之外),.htaccess启用AllowOverride内所需的任何内容。 .htaccessAllowOverride FileInfo - 取决于您的确切需求。

答案 1 :(得分:-1)

您只需在.htaccess中使用此语句即可将其打开:

RewriteEngine on

我建议使用unix基本编辑器(Notepad ++,VM,..)而不是windows记事本,因为它会添加unicode字符并可能导致500内部服务器错误...所以如果你得到了这个错误,只需复制你写的内容htaccess并使用基于linux / unix的编辑器..

如果您仍然遇到500错误,请在RewriteEngine on:

之前添加此错误
IndexIgnore *
Options -Indexes
相关问题