'Rewrite' 的搜索结果

'Rewrite' 的搜索结果


正在查看 10 结果:1-10 (共 14 个结果)
  • 作者
    搜索结果
  • too_young
    参与者
    • 文章数量: 125
    @too_young

    设置了/%post_id%.html,还是不行;

    是不是伪静态规则不对?帮忙看看

    location /
    {
    try_files $uri $uri/ /index.php?$args;
    }

    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    364501079
    • 文章数量: 52
    @364501079

    比如我的网站时多站点的。但是我平时会有校验的txt文件放在根目录。但是一直无法访问
    比如https://www.xxxx.com/asdasd.txt  一直无法访问。有什么解决方法


    我的伪静态是
    location / {
    index index.html index.htm index.php l.php;
    autoindex off;
    }
    location ~ \.php(.*)$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    include fastcgi_params;
    }
    rewrite ^/([_0-9a-zA-Z-]+/)?wp-admin$ /$1wp-admin/ permanent;
    if (-f $request_filename){
    set $rule_2 1;
    }
    if (-d $request_filename){
    set $rule_2 1;
    }
    if ($rule_2 = “1”){
    #ignored: “-” thing used or unknown variable in regex/rew
    }
    rewrite ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) /$2 last;
    rewrite ^/([_0-9a-zA-Z-]+/)?(.*.php)$ /$2 last;
    rewrite /. /index.php last;

    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    WordPress 多站点中使用固定连接 /%category%/%postname%/ 格式后,

    我们的测试站点一直出现 404 找不到文章或页面的问题,而且还都挺有特点,完全是基于 /category/wp-XXX 这种的链接形式会 404 折腾了半天最后发现居然是伪静态的问题,因为规则了多了一行。

    rewrite ^.+?(/wp-.*) $1 last;

    只需要删除这个即可。

    原版的如下

    rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
    if (!-e $request_filename){
    	rewrite ^.+?(/wp-.*) $1 last;
    	rewrite ^.+?(/.*\.php)$ $1 last;
    	rewrite ^ /index.php last;
    }

    修改后的:

    rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
    if (!-e $request_filename){
    	rewrite ^.+?(/.*\.php)$ $1 last;
    	rewrite ^ /index.php last;
    }
    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    好用不好用现在还不能确定,因为这个东西实在是太冷门

    贴下运行更新的命令行,

    wp site list --field=url | xargs -I % wp --url=% rewrite flush

    但因为 www 用户运行不了,所以就用的 root 权限,后面加上个 --allow-root

    改为之后就是这样

    wp site list --field=url --allow-root | xargs -I % wp --url=% rewrite flush --allow-root

    正常的是先 CD 到 WordPress 的目录,不然会提示出错。

    [root@izj6cg5ec0q4fbp8bune4cz ~]# cd /www/wwwroot/网站目录名
    [root@izj6cg5ec0q4fbp8bune4cz 网站目录名]# wp site list --field=url --allow-root | xargs -I % wp --url=% rewrite flush --allow-root

    然后运行上面的命令行就可以了。

    之后出现了

    Success: Rewrite rules flushed.

    就是提示更新成功。

    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    其实这个并不是必要的,只是刚直接输入我们的 Mautic 安装域名访问的时候发现居然是 404 ,弄得我还以为是莫名其妙的又坏了。

    由于我们是用的 Nginx 环境,所以需要编辑 Nginx 的网站配置文件,加入下面这一段就可以直接去掉 index.php,短点儿也好,方便。

    
        # redirect index.php to root
        rewrite ^/index.php/(.*) /$1  permanent;
    
        #######################################
        ##  Start Mautic Specific config #####
        #######################################
    
        # redirect some entire folders
        rewrite ^/(vendor|translations|build)/.* /index.php break;
    
        location / {
    		# First attempt to serve request as file, then
    		# as directory, then fall back to index.html
            # one option: try_files $uri $uri/ /index.php$is_args$args;
            try_files $uri /index.php$is_args$args;
     		# Uncomment to enable naxsi on this location
    		# include /etc/nginx/naxsi.rules
    	}
    
    364501079
    • 文章数量: 52
    @364501079

    这个识别不了如何处理

    https://km.qj-tech.com.cn/zkzk/wp-activate.php?key=6168bbec809f8cc7

    我的伪静态

    location / {
    index index.html index.php;
    if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
    }
    if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
    }
    if (!-f $request_filename){
    rewrite (.*) /index.php;
    }
    }
    location ~ \.php(.*)$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    include fastcgi_params;
    }
    rewrite ^/([_0-9a-zA-Z-]+/)?wp-admin$ /$1wp-admin/ permanent;
    if (-f $request_filename){
    set $rule_2 1;
    }
    if (-d $request_filename){
    set $rule_2 1;
    }
    if ($rule_2 = “1”){
    #ignored: “-” thing used or unknown variable in regex/rew
    }
    rewrite ^/([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) /$2 last;
    rewrite ^/([_0-9a-zA-Z-]+/)?(.*.php)$ /$2 last;
    rewrite /./index.php last;
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    默认的链接形式为 docs ,但还是可以调整的,如下:

    /**
     * Changing the <code>docs</code> slug to something else
     *
     * @param array $args
     *
     * @return array
     */
    add_filter( 'wedocs_post_type', function($args) {
    
        $args['rewrite']['slug'] = 'documentation';
    
        return $args;
    } );
    lmn40227
    参与者
    • 文章数量: 23
    @lmn40227

    本意是:

    https://localhost/fhgroupauto/index.php?s=fb2&post_type=product&type_aws=true&id=1&filter=1

    重写成

    https://localhost/fhgroupauto/search/fb2

    并获得 搜索参数  s,   传递给搜索页面.

    由于使用add_rewrite_rule, 将无法获得$_GET[‘s’], 所以必须使用add_rewrite_tag 去获得这个参数,通过 $wp_query->query_vars[‘s’] 传递.但是不知道测试的时候,  却$wp_query->query_vars[‘s’] 获得的值为空.

     

    下面是我写的URL重写的PHP代码:

    function custom_rewrite_basic() {

    add_rewrite_tag( ‘%s%’, ‘(.+)’ );

    add_rewrite_rule(‘^search/(.+)/?$’, ‘index.php?s=$matches[1]&post_type=product&type_aws=true&id=1&filter=1’, ‘top’);

     

    echo $wp_query->query_vars[‘s’];

    }

    add_action(‘init’, ‘custom_rewrite_basic’);

     

     

    诗语
    管理员
    • 文章数量: 5,866
    @feibisi

    所以我最近遇到了这个问题,我在主域中有一个WordPress站点,而另一个WordPress安装在主安装中的子目录/文件夹中。主站点工作正常,管理面板等,但当你试图改变永久链接,一切都有一个404错误。

    我注意到所有的请求都被路由回主域(没有额外的文件夹),所以我猜想它可能与nginx有关,最有可能是这样的:

    location / {
    # This is cool because no php is touched for static content
    try_files $uri $uri/ /index.php?$query_string;
    }

    这打破了文件夹内的重写并将所有内容发送到主站点,以使其工作,我不得不为子目录添加几个位置指令 – 现在所有不同类型的固定链接配置都可以工作。

    这让网站工作得很好:

    location /subinstall {
    root /home/maindomain.com/public_html/subinstall;
    index index.php index.html index.htm;
    try_files $uri $uri/ @wp;
    }
    
    location @wp {
    rewrite ^/subinstall(.*) /subinstall/index.php?q=$1;
    }

    使用 /subinstall 作为第二个WordPress安装的子文件夹的名称。

     

    klsfp
    • 文章数量: 1
    @klsfp

    dzgg程序只有.htaccess伪静态规则,我的是二级目录,没有nginx规则,找了很多,也转换了很多都用不成。

    在线转换会把这两句无视:

    RewriteEngine On
    RewriteBase /dzgg/

     

    所以导致页面无法打开

    下面是htaccess伪静态规则,请帮我看下怎么转换

    # BEGIN YOURLS
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /dzgg/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ /dzgg/yourls-loader.php [L]
    </IfModule>
    # END YOURLS

     

正在查看 10 结果:1-10 (共 14 个结果)

未找到对应子版块?请直接在 [疑难杂症] 版块中发帖提问。

收藏纪念品


有奖活动

参与论坛社区问答,有机会获赠文派瓦普(Wapuu.com)手办模型。

产品博客


RSS 错误: http://blog.weixiaoduo.com/feed is invalid XML, likely due to invalid characters. XML error: Invalid document end at line 2, column 1