Apache ';nginx重写&x27;至';。htacces重写&x27;

Apache ';nginx重写&x27;至';。htacces重写&x27;,apache,nginx,rewrite,Apache,Nginx,Rewrite,我在regexps中很差,但在服务器配置中我最差。 所以任何帮助都是有用的 在nginx配置中有这样的功能 location / { rewrite ^(.*[^/])$ $1/ permanent; try_files $uri $uri/ /index.php?$args; } 需要同样的东西。 泰。他们应该证明非常相似 <IfModule mod_rewrite.c> RewriteEngine On # Your web directory

我在regexps中很差,但在服务器配置中我最差。 所以任何帮助都是有用的

在nginx配置中有这样的功能

location / {
    rewrite ^(.*[^/])$ $1/ permanent;
    try_files $uri $uri/ /index.php?$args;
}
需要同样的东西。
泰。

他们应该证明非常相似

<IfModule mod_rewrite.c>
    RewriteEngine On
    # Your web directory root
    RewriteBase /

    #Make sure it's not a specific file or directory that they're trying to reach
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d

    RewriteRule ^(.*[^/])$ index.php?args=$1 [NC, L]
</IfModule>

重新启动发动机
#您的web目录根
重写基/
#确保他们试图访问的不是特定的文件或目录
重写cond%{SCRIPT_FILENAME}-F
重写cond%{SCRIPT_FILENAME}-D
重写规则^(.*[^/])$index.php?args=$1[NC,L]
这将:

  • 将.htaccess所在文件夹的RewriteEngine标记为on(如果已启用该模块)
  • 如果文件是服务器上的目录或文件,请指定避免重定向的条件;及
  • 将正则表达式重定向到index.php?args={正则表达式捕获的所有内容}
  • [NC,L]标志告诉规则区分大小写,并分别告诉Apache这是最后一条重定向规则

    我必须承认,我不确定你的正则表达式测试的目的是什么。你介意解释一下你想建立的URL方案吗?我应该能够帮助你正确地制定正则表达式