gpt4 book ai didi

php - RewriteEngine 不在本地重写 URL?

转载 作者:可可西里 更新时间:2023-11-01 00:37:05 26 4
gpt4 key购买 nike

Options +FollowSymlinks

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f # not a file
RewriteCond %{REQUEST_FILENAME} !-d # not a directory
RewriteRule ^(.+)$ index.php?params=$1 [L]

如你所见,我正在尝试转换任何类似的东西

mysite.com/x/y/z

mysite.com/index.php?params=x/y/z

但是,它不起作用。我尝试了 mysite.com/home 并在 index.php 的第一行放置了一个断点,但得到了 404。

关于为什么这对我不起作用的任何想法?谢谢你!

最佳答案

首先,确保在您的 Apache 服务器上启用了 mod_rewrite

然后去掉行尾的注释:

# not a file
RewriteCond %{REQUEST_FILENAME} !-f
# not a directory
RewriteCond %{REQUEST_FILENAME} !-d

From the Apache documentation :

Lines which begin with the hash character "#" are considered comments, and are ignored. Comments may not be included on a line after a configuration directive.

关于php - RewriteEngine 不在本地重写 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4846339/

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