apache .htaccess重写

编程入门 行业动态 更新时间:2024-10-28 00:16:43
本文介绍了apache .htaccess重写-我可以将其移到httpd.conf中吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

以下是我在Apache 2.2中的 .htaccess 文件中唯一的代码。

Below is the only code I have in the .htaccess file with apache 2.2.

我已经读到使用 .htacess 会对性能产生影响,如果可以运行,效果会更好从 httpd.conf 中删除​​。因此,是否可以将其添加到 httpd.conf 中?如果是这样,我会放在哪里?

I've read that its a performance impact to use a .htacess and better if this this can be run out of httpd.conf. Therefore is it possible for me to add this into httpd.conf? If so where would I put it?

是否需要为每个需要它的主机(在我的情况下为很多主机)进入VirtualHost,或者可以通用地进入httpd.conf以便应用

Would it need to go into the VirtualHost for each Host that needed it (in my case a lot of hosts) or could it go generically into httpd.conf so it applies to all hosts?

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule>

推荐答案

.htaccess 提供目录的配置,而httpd.conf提供整体配置。当然,您可以将内容从 .htaccess 移到 httpd.conf 。 您可以在此处找到有关.htaccess的更多信息: Apache HTTP Server教程:.htaccess文件

.htaccess provides configuration for a directory, while httpd.conf provides an overall configuration. Of course, you can move content from .htaccess to httpd.conf. You can find more about .htaccess here: Apache HTTP Server Tutorial: .htaccess files

以您的.htaccess为例:

Take your .htaccess for example:

/ www / htdocs / example中.htaccess文件的内容

Contents of .htaccess file in /www/htdocs/example

<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule>

您的httpd.conf文件中的部分

Section from your httpd.conf file

<Directory /www/htdocs/example> <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?/$1 [L] </IfModule> </Directory>

更多推荐

apache .htaccess重写

本文发布于:2023-07-16 04:05:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117664.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   apache   htaccess

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!