自定义URL或隐藏查询字符串使用的.htaccess [英] Customize Url or Hide Query String using .htaccess

查看:243
本文介绍了自定义URL或隐藏查询字符串使用的.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的,我学的.htaccess 。我想定制我的网址 从 的index.php?网页=移动指数/页/移动

我用这个code,但它不工作:

  RewriteEngine叙述上
重写规则^指数/([0-9] +)/ $的index.php?网页= $ 1 [NC,L]#拉手产品的要求
 

  RewriteEngine叙述上
重写规则^指数/([^/.]+)/?$的index.php?网页= $ 1 [L]
 

解决方案

这个规则应该工作:

  RewriteEngine叙述上
的RewriteBase / cashearn /

的RewriteCond%{} THE_REQUEST /index\.php\?page=([^\s&]+)[NC]
重写规则^指数/页/ 1%? [R = 302,L]

的RewriteCond%{} REQUEST_FILENAME!-d
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^指数/页/([^ /] +)/ $的index.php?网页= $ 1 [L,QSA,NC]
 

这会让你有网址为 http://domain.com/index/page/mobile 您的网页上。

I am new one, I learn .htaccess. I want to customize my URL from index.php?page=mobile to index/page/mobile

I used this code but it doesn't work:

RewriteEngine on
RewriteRule    ^index/([0-9]+)/?$    index.php?page=$1    [NC,L]    # Handle product requests

and

RewriteEngine on
RewriteRule ^index/([^/.]+)/?$ index.php?page=$1 [L]

解决方案

This rule should work:

RewriteEngine on
RewriteBase /cashearn/

RewriteCond %{THE_REQUEST} /index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ index/page/%1? [R=302,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index/page/([^/]+)/?$ index.php?page=$1 [L,QSA,NC]

This will let you have URL as http://domain.com/index/page/mobile on your page.

这篇关于自定义URL或隐藏查询字符串使用的.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆