dongzipu7517 2014-07-07 20:25
浏览 31
已采纳

从.htaccess中的网址中删除“&title”

I'm trying to create shorter urls to some of my pages.

Previously I had a system that URLs were like /index.php?m=page&title=Page-Title

The piece of code I have now allows me to remove the everything 'm=' part. /index.php?m=page in here, the 'page' is a name of different modules, so this part might still change. I want to change the url only from 'page'.

How would I rewrite this so that my URL would be composed only as such:

/page=Page-Title

Would that be even possible since I'm using $_GET in 2 places?

My current .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/?p=$1 [L]
  • 写回答

1条回答 默认 最新

  • douping5015 2014-07-07 20:30
    关注

    You can have your rules like this:

    RewriteEngine On
    
    RewriteRule ^page=([^/]+)/?$ /index.php?p=page&t=$1 [L,QSA,NC]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php/?p=$1 [L,QSA]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据