繁体   English   中英

mod_rewrite指向site.com/something到index.php?values = something

[英]mod_rewrite to direct site.com/something to index.php?values=something

(我可能是个白痴,似乎默认情况下在OSX上的Apache中没有启用.htaccess。)

我知道那里有很多mod_rewrite的问题,但是我不能让我的权利得到正确而且其他任何东西似乎都无法覆盖它。

我想做的就是重定向

www.url.com/something

要么

www.url.com/something/anything/more

www.url.com/index.php?values=something

要么

www.url.com/index.php?values=something/anything/more

没有比这更好的了(我会放弃一些忽略gif / jpg / png的东西,稍后再添加www等) - 所有处理的东西/任何/更多将在PHP中完成。

我不能说得对。 任何提示/资源或任何刚刚设法做到这一点的人? 知道我曾经把它完美地完美但几年前失去了那些代码,这更令人沮丧。

RewriteEngineOn
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d    
RewriteRule ^(.*)$ /index.php?values=$1 [L]

请注意,如果您尝试在.htaccess文件中执行此操作,则需要在Apache主机配置文件中为相关目录设置AllowOverride On,当然需要启用mod_rewrite模块。

此规则将忽略实际存在的任何实际文件或目录(即图像)的重定向(包括index.php)。

这是非常简单的,至少在你要求的内容但是基本上你需要使index.php passthrough(所以你不要将index.php重写 index.php),然后是主要的重写。

RewriteEngine On
RewriteRule index.php - [L]

# your conditions here
RewriteRule ^/?(.*)$ /index.php?values=$1 [L]

在#your # your conditions here spot添加您想要排除重写# your conditions here

暂无
暂无

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

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