gpt4 book ai didi

mod-rewrite - 从 MAMP 到 Ubuntu/Apache2 的不同 .htaccess 和 mod_rewrite 结果

转载 作者:行者123 更新时间:2023-12-04 18:53:11 25 4
gpt4 key购买 nike

我的网站(MAMP)的本地版本似乎得到了与我的 Ubuntu 服务器不同的 mod_rewrite 结果。

例如,当我输入

http://gymtracker.in/articles

它应该在内部转换为

http://gymtracker.in/articles.php

对于服务器,但它只是抛出 404 错误。

我已经确认我的 .htaccess 文件正在被读取,它在放置垃圾时会引发错误。

这是重写日志的输出

`110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cd0a0/subreq] (3) [perdir /var/www/] strip per-dir prefix: /var/www/articles.php -> articles.php
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cd0a0/subreq] (3) [perdir /var/www/] applying pattern '^article/([a-zA-Z0-9-]*)' to uri 'articles.php'
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cd0a0/subreq] (3) [perdir /var/www/] strip per-dir prefix: /var/www/articles.php -> articles.php
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cd0a0/subreq] (3) [perdir /var/www/] applying pattern '(.*)' to uri 'articles.php'
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cd0a0/subreq] (4) [perdir /var/www/] RewriteCond: input='/var/www/articles.php' pattern='!-d' => matched
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cd0a0/subreq] (4) [perdir /var/www/] RewriteCond: input='/var/www/articles.php' pattern='!-f' => not-matched
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cd0a0/subreq] (1) [perdir /var/www/] pass through /var/www/articles.php
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cf0a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/favicon.ico -> favicon.ico
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cf0a0/initial] (3) [perdir /var/www/] applying pattern '^article/([a-zA-Z0-9-]*)' to uri 'favicon.ico'
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cf0a0/initial] (3) [perdir /var/www/] strip per-dir prefix: /var/www/favicon.ico -> favicon.ico
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cf0a0/initial] (3) [perdir /var/www/] applying pattern '(.*)' to uri 'favicon.ico'
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cf0a0/initial] (4) [perdir /var/www/] RewriteCond: input='/var/www/favicon.ico' pattern='!-d' => matched
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cf0a0/initial] (4) [perdir /var/www/] RewriteCond: input='/var/www/favicon.ico' pattern='!-f' => not-matched
110.175.32.14 - - [21/Aug/2013:00:44:38 +1000] [gymtracker.in/sid#7f6c27b8d430][rid#7f6c279cf0a0/initial] (1) [perdir /var/www/] pass through /var/www/favicon.ico

这也是我的 .htacess 文件的输出
Options +FollowSymLinks

RewriteEngine on

RewriteRule ^article/([a-zA-Z0-9-]*) /article.php?title=$1

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]

当配置看起来相同时,我只是不确定为什么它在我的本地 Web 服务器上运行,而不是在我的远程服务器(ubuntu)上运行。

最佳答案

假设你有你的 .htaccess在网络根目录 /尝试

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /

RewriteRule ^article/([a-zA-Z0-9-]*) /article.php?title=$1 [NC,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ $1.php [L]

关于mod-rewrite - 从 MAMP 到 Ubuntu/Apache2 的不同 .htaccess 和 mod_rewrite 结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18338362/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com