Php .htaccess删除“;?第页=”;

Php .htaccess删除“;?第页=”;,php,regex,.htaccess,mod-rewrite,friendly-url,Php,Regex,.htaccess,Mod Rewrite,Friendly Url,我有两个问题,都是相关的: 使用示例url: 如何使用.htaccess将其写为: 第二部分 使用示例url: 如何使用.htaccess将其写为: 编辑: 为了响应,请显示您当前的.htaccess # php -- BEGIN cPanel-generated handler, do not edit # Set the “ea-php74” package as the default “PHP” programming language. <IfModule mime_mod

我有两个问题,都是相关的:

  • 使用示例url:
  • 如何使用.htaccess将其写为:

    第二部分

  • 使用示例url:
  • 如何使用.htaccess将其写为:

    编辑:

    为了响应,请显示您当前的.htaccess

    # php -- BEGIN cPanel-generated handler, do not edit
    # Set the “ea-php74” package as the default “PHP” programming language.  
     <IfModule mime_module>
       AddHandler application/x-httpd-ea-php74___lsphp .php .php7 .phtml
     </IfModule>
    # php -- END cPanel-generated handler, do not edit
    
    ## Redirects the index.php file to the root domain
    RewriteRule ^index.php$ https://www.digitleseo.com/ [R=301,L]
    
    #redirect  /file.php to /file
    RewriteRule ^(.+).php$ /$1 [L,R]
    # now we will internally map /file to /file.php
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)/?$ /$1.php [END]
    
    #php--开始cPanel生成的处理程序,不要编辑
    #将“ea-php74”包设置为默认的“PHP”编程语言。
    AddHandler应用程序/x-httpd-ea-php74_uuuuulsphp.php.php7.phtml
    #php——结束cPanel生成的处理程序,不编辑
    ##将index.php文件重定向到根域
    重写规则^index.php$https://www.digitleseo.com/ [R=301,L]
    #将/file.php重定向到/file
    重写规则^(+).php$/$1[L,R]
    #现在我们将在内部将/file映射到/file.php
    RewriteCond%{REQUEST_FILENAME}.php-f
    重写规则^(.*)/?$/$1.php[结束]
    
    这是我的文件htaccess,我用它来删除controler,并将控制器名称保留为path,操作名称保留为path

    <IfModule mod_rewrite.c>
    
        RewriteEngine on
        ErrorDocument 404 http://shop.local/error/index
    
        RewriteCond %{SCRIPT_FILENAME} !-d
        RewriteCond %{SCRIPT_FILENAME} !-f
    
        RewriteRule ^(.*)/(.*) index.php?controller=$1&action=$2
    </IfModule>
    
    
    重新启动发动机
    错误文档404http://shop.local/error/index
    重写cond%{SCRIPT_FILENAME}-D
    重写cond%{SCRIPT_FILENAME}-F
    重写规则^(.*)/(.*)index.php?控制器=$1和操作=$2
    
    这是我的文件htaccess,我用它来删除controler,并将控制器名称保留为path,操作名称保留为path

    <IfModule mod_rewrite.c>
    
        RewriteEngine on
        ErrorDocument 404 http://shop.local/error/index
    
        RewriteCond %{SCRIPT_FILENAME} !-d
        RewriteCond %{SCRIPT_FILENAME} !-f
    
        RewriteRule ^(.*)/(.*) index.php?controller=$1&action=$2
    </IfModule>
    
    
    重新启动发动机
    错误文档404http://shop.local/error/index
    重写cond%{SCRIPT_FILENAME}-D
    重写cond%{SCRIPT_FILENAME}-F
    重写规则^(.*)/(.*)index.php?控制器=$1和操作=$2
    
    这应该适合您

    RewriteEngine on
    #redirect /?page=foobar.php to /foobar
    RewriteCond %{THE_REQUEST} \s/(?:index\.php)?\?page=([^.]+)\.php [NC]
    RewriteRule .* /%1? [L,R]
    ###the rule bellow will internally forward the new URL to the old one
    # not an existent file
    RewriteCond %{REQUEST_FILENAME} !-f
    #not a directory
    RewriteCond %{REQUEST_FILENAME} !-d
    #rewrite the request /foo/bar to /?page=foo/bar.php
    RewriteRule ^(.+)/?$ /?page=$1.php [L,END]
    

    这应该对你有用

    RewriteEngine on
    #redirect /?page=foobar.php to /foobar
    RewriteCond %{THE_REQUEST} \s/(?:index\.php)?\?page=([^.]+)\.php [NC]
    RewriteRule .* /%1? [L,R]
    ###the rule bellow will internally forward the new URL to the old one
    # not an existent file
    RewriteCond %{REQUEST_FILENAME} !-f
    #not a directory
    RewriteCond %{REQUEST_FILENAME} !-d
    #rewrite the request /foo/bar to /?page=foo/bar.php
    RewriteRule ^(.+)/?$ /?page=$1.php [L,END]
    

    谢谢你,阿米特。我明白为什么这会奏效。但这不是出于某种原因。我的文件结构在场景背后重要吗?e、 g.example.com/?page=services.php正在为来自/content/services.php的页面提供服务。php正在检查变量页面并基于该页面输出result@scriptmonkey我发布的规则只重写以下格式的请求URI
    /foo
    /foo/bar
    。键入
    /foo
    时会发生什么情况?您是否在同一URI上看到了
    /?page=foo
    的内容?/foo给出了/?page=foo.php的内容。。。但是,当我导航到/?page=foo.php时,它不会被重写为/foo@scriptmonkey基本标签在链接的SO帖子中提到。请再次阅读我上面的评论。谢谢你,阿米特!!谢谢你,阿米特。我明白为什么这会奏效。但这不是出于某种原因。我的文件结构在场景背后重要吗?e、 g.example.com/?page=services.php正在为来自/content/services.php的页面提供服务。php正在检查变量页面并基于该页面输出result@scriptmonkey我发布的规则只重写以下格式的请求URI
    /foo
    /foo/bar
    。键入
    /foo
    时会发生什么情况?您是否在同一URI上看到了
    /?page=foo
    的内容?/foo给出了/?page=foo.php的内容。。。但是,当我导航到/?page=foo.php时,它不会被重写为/foo@scriptmonkey基本标签在链接的SO帖子中提到。请再次阅读我上面的评论。谢谢你,阿米特!!完美的