ReWriteRule 是重定向而不是重写

发布于 2024-09-05 22:59:19 字数 971 浏览 3 评论 0原文

目前我有两台机器用于进行 Web 开发; iMac 适合在办公室工作,MacBook 则适合在旅途中工作。它们都运行 OS X 10.6,并运行相同版本的 PHP、Apache 等。

两台计算机都有相同的网站文件,包括 .htaccess 文件(见下文)。在 MacBook 上,URL 被很好地重写,屏蔽了它们指向的 URL(例如 site/page/page-name),但是在 iMac 上,它们只是重定向到页面(例如 site/index.php?method=page&value) =页面名称)这使得在机器之间来回切换有点痛苦!

我确信它一定是某个地方的配置设置,但我一生都找不到它。有人有补救办法吗?非常感谢。

我相当确信有一种很好的方法可以编写此 htaccess 文件,而不会失去对几个关键文件夹的访问权限!

Options +FollowSymlinks
RewriteEngine on

RewriteBase /In%20Progress/Vila%20Maninga/

RewriteRule ^page/([a-z|0-9_&;=-]+) index.php?method=page&value=$1 [NC]
RewriteRule ^tag/([a-z|0-9_]+) index.php?method=tag&value=$1 [NC]
RewriteRule ^search/([a-z|0-9_"]+) index.php?method=search&value=$1 [NC]
RewriteRule ^modpage/([con0-9-]+) index.php?method=modpage&value=$1 [NC]
RewriteRule ^login index.php?method=login [NC]
RewriteRule ^logout index.php?method=logout [NC]
RewriteRule ^useraccounts index.php?method=useraccounts [NC]

At the moment I have two machines that I do web development on; an iMac for work at the office and a MacBook for when I have to work on the move. They both running OS X 10.6 have the same version of PHP, Apache, etc running on them.

Both computers have the same files of the website, including the .htaccess file (see below). On the MacBook the URLs are rewritten nicely, masking the URL they are pointing to (eg site/page/page-name), however on the iMac they simply redirect to the page (eg site/index.php?method=page&value=page-name) which is making switching back and forth between machines a bit of a pain!

I'm sure it must be a config setting somewhere, but I can't for the life of me find it. Has anyone got a remedy? Many thanks.

I'm fairly convinced there is a much nice way of writing this htaccess file without loosing access several key folders as well!

Options +FollowSymlinks
RewriteEngine on

RewriteBase /In%20Progress/Vila%20Maninga/

RewriteRule ^page/([a-z|0-9_&;=-]+) index.php?method=page&value=$1 [NC]
RewriteRule ^tag/([a-z|0-9_]+) index.php?method=tag&value=$1 [NC]
RewriteRule ^search/([a-z|0-9_"]+) index.php?method=search&value=$1 [NC]
RewriteRule ^modpage/([con0-9-]+) index.php?method=modpage&value=$1 [NC]
RewriteRule ^login index.php?method=login [NC]
RewriteRule ^logout index.php?method=logout [NC]
RewriteRule ^useraccounts index.php?method=useraccounts [NC]

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

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

发布评论

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

评论(1

燕归巢 2024-09-12 22:59:19

检查以确保 MultiViews 指令已禁用,因为它可能会导致此问题。

Check to ensure the MultiViews directive is disabled, as it may be causing this.

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