douzui0143 2016-10-09 15:44
浏览 17

重写具有多个页面的网址

I'm trying to rewrite my urls on a page that has a pagination option and I'm unsure of what string to use because the one i'm currently using isn't working.

My document structure is below

  • blog-listing.php
  • htaccess
  • /blog/post.php
  • /css/
  • /js/
  • /images/

What's already in my htaccess file

RewriteEngine on
RewriteRule ^blog/category/([a-zA-Z0-9-/]+)$ /blog/archive.php?cat=$1 [L]
RewriteRule ^blog/category/([a-zA-Z0-9-/]+)/page/([0-9]+)/{0,1}$ /blog/archive.php?cat=$1&page=$2 [L]
RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]
RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1&page=$2 [L]

RewriteRule ^(css)($|/) - [L]
RewriteRule ^(perch)($|/) - [L]
RewriteRule ^(images)($|/) - [L]
RewriteRule ^(js)($|/) - [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

The line i've tried to use

RewriteRule ^blog-listing/([a-zA-Z0-9-/]+)$ /blog-listing.php?s=$1&page=$2 [L]

The url I'm receiving

http://mysite(dot)com/blog-listing.php?page=2

The url I'd like

http://mysite(dot)com/blog-listing/page-2

Any ideas?

  • 写回答

1条回答 默认 最新

  • dongmaoxi0477 2016-10-09 15:56
    关注

    Use a simple file to manage your url

    RewriteEngine On
    
    # Redirect all requests not pointing at an actual file to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . index.php [L] 
    

    https://github.com/ogallardop/blackjack-api/blob/master/src/.htaccess

    The framework you're using to pagination will do the rest.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c