Php laravel 4重写分页url

Php laravel 4重写分页url,php,.htaccess,pagination,laravel-4,Php,.htaccess,Pagination,Laravel 4,我使用Laravel分页,但url如下所示: http://mydomain.com/?page=2 http://mydomain.com/page/2 我更喜欢这样的url: http://mydomain.com/?page=2 http://mydomain.com/page/2 我有权访问: <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiVi

我使用Laravel分页,但url如下所示:

http://mydomain.com/?page=2
http://mydomain.com/page/2
我更喜欢这样的url:

http://mydomain.com/?page=2
http://mydomain.com/page/2
我有权访问:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</IfModule>

但itt不起作用。。。有什么想法吗?可以使用
.htaccess
文件以外的其他文件吗?

据我所知,Laravel的默认分页系统不支持您正在寻找的路由类型

由于应用程序中的每个页面的路由外观都可能非常不同,因此很难在.htaccess中提供一个全面重写规则,该规则将以Laravel能够理解的格式正确重写URL,同时也不会干扰其他URL参数和路径


对于您的特定示例,但这仅适用于您的特定示例,而不适用于其他示例,您可以尝试以下方法:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    #Handle pagination for urls like http://mydomain.com/page/2
    RewriteRule ^page/([0-9]+)$ index.php?page=$1

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</IfModule>

选项-多视图
重新启动发动机
#重定向尾部斜杠。。。
重写规则^(.*)/$/$1[L,R=301]
#处理URL的分页,如http://mydomain.com/page/2
重写规则^page/([0-9]+)$index.php?page=$1
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
同样,此不是一般的解决方案,仅适用于以下链接(而不适用于以下链接)