简体   繁体   English

RewriteEngine不在本地重写URL?

[英]RewriteEngine not Rewriting URL locally?

Options +FollowSymlinks

RewriteEngine on

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

as you can see, i'm trying to convert anything like 正如你所看到的,我正试图转换任何类似的东西

mysite.com/x/y/z mysite.com/x/y/z

to

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

however, it is not working. 但它没有用。 i tried mysite.com/home and put a breakpoint on the first line in index.php, but got a 404. 我试过mysite.com/home并在index.php的第一行放了一个断点,但得到了404。

any ideas as to why this isn't working for me? 关于为什么这不适合我的任何想法? thanks for anything! 谢谢!

First, make sure mod_rewrite is enabed on your Apache server. 首先,确保在Apache服务器上启用mod_rewrite

Then remove the comments at the end of the lines: 然后删除行尾的注释:

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

From the Apache documentation : 从Apache文档

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. 配置指令后,注释可能不包含在一行中。

It seems, that either mod_rewrite is not installed, or enabled, or that you have set the AllowOverride -directive for the specific directory to None . 似乎没有安装或启用mod_rewrite ,或者您已将特定目录的AllowOverride -directive设置为None Change it to (at least) FileInfo 将其更改为(至少) FileInfo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM