将 .htaccess 集成到 httpd.conf 中

发布于 2024-10-31 17:35:58 字数 744 浏览 5 评论 0原文

我在 /connect 文件夹中有以下 htaccess 文件,我需要将其集成到 httpd.conf 文件(已包含命令):

/connect/.htaccess

SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteBase /connect
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

httpd.conf

...
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/html/alter
ServerName www.mysite.com

 <IfModule mod_rewrite.c>
    RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
...
....

我不确定如何适应上述内容进入下面?

I'vee got the following htaccess file in /connect folder and I need to integrate this into an httpd.conf file (which has commands already):

/connect/.htaccess

SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteBase /connect
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

httpd.conf

...
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/html/alter
ServerName www.mysite.com

 <IfModule mod_rewrite.c>
    RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
...
....

I'm not sure how I can fit the above into the below?

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

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

发布评论

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

评论(1

半步萧音过轻尘 2024-11-07 17:35:58

.htaccess 本质上是 httpd.conf 中块的核心,因此您需要类似的内容

<Virtualhost *:80>
   DocumentRoot ...
   ServerName ...
   etc....
   <Directory /var/www/html/alter>
      ... guts of .htaccess here ...
   </Directory>
</VirtualHost>

,但是,只有在您确信 .htaccess 正常工作并且不会被更改(很多)后,您才应该有这样的机会)不再。对 httpd.conf 的任何更改都需要您退回服务器,而 .htaccess 更改会立即对下一个请求生效。

A .htaccess is essentially the guts of a block in httpd.conf, so you'd want something like

<Virtualhost *:80>
   DocumentRoot ...
   ServerName ...
   etc....
   <Directory /var/www/html/alter>
      ... guts of .htaccess here ...
   </Directory>
</VirtualHost>

Though, you should only make such a chance once you're satisified that the .htaccess is working properly and will not be changed (much) anymore. Any changes to httpd.conf require you to bounce the server, while .htaccess changes take effect immediately for the next request.

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