Apache 修改重写替换链接

Apache 修改重写替换链接,apache,mod-rewrite,url-rewriting,Apache,Mod Rewrite,Url Rewriting,需要帮助来替换任何链接,如: http://www.domain.com/index.php/download?file=WQE875487 到 只有在以下情况下: index.php/download?file= 需要将其替换为: download?file= 因为我也在使用index.php进行其他操作。您可以尝试以下操作: # Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase /

需要帮助来替换任何链接,如:

http://www.domain.com/index.php/download?file=WQE875487

只有在以下情况下:

index.php/download?file=
需要将其替换为:

download?file=

因为我也在使用index.php进行其他操作。

您可以尝试以下操作:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

你的规则是

RewriteRule index\.php/download\?file=([a-zA-Z0-9]*) download?file=$1
如果您在没有下载信息的情况下使用index.php,它将不会重定向。如果不指定文件=(index.php/download将不重定向),它将不会重定向

不过index.php/download?file=将起作用。如果您不想让它处理空文件,只需将asterix更改为加号

RewriteRule index\.php/download\?file=([a-zA-Z0-9]+) download?file=$1

PS-我不知道您的文件值是否可以使用字母和数字以外的其他内容[a-zA-Z0-9]。根据您的使用情况对其进行相应的更改。

这没有帮助,正如我所说,我也在使用index.php进行其他操作。仅当附带:index.php/download?file=需要将其替换为:download?file=它始终使用索引文件,因此:如果您没有更改apache配置中的索引文件设置,则等于。
RewriteRule index\.php/download\?file=([a-zA-Z0-9]+) download?file=$1