简体   繁体   English

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

[英]Removing '&title' from the URL in .htaccess

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 以前我有一个系统,网址就像/index.php?m=page&title=Page-Title

The piece of code I have now allows me to remove the everything 'm=' part. 我现在的代码片段允许我删除所有'm ='部分。 /index.php?m=page in here, the 'page' is a name of different modules, so this part might still change. /index.php?m=page在这里,'page'是不同模块的名称,因此这部分可能仍会改变。 I want to change the url only from 'page'. 我想仅从“页面”更改网址。

How would I rewrite this so that my URL would be composed only as such: 我将如何重写这个,以便我的URL只能这样组成:

/page=Page-Title

Would that be even possible since I'm using $_GET in 2 places? 这是否可能,因为我在2个地方使用$_GET

My current .htaccess file: 我目前的.htaccess文件:

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

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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM