简体   繁体   English

使用.htaccess自定义网址或隐藏查询字符串

[英]Customize Url or Hide Query String using .htaccess

I am new one, I learn .htaccess . 我是新手,我学习.htaccess I want to customize my URL from index.php?page=mobile to index/page/mobile 我想自定义URL,从index.php?page=mobileindex/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设置为http://domain.com/index/page/mobile

Try that code: 尝试该代码:

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

这应该工作-尽管未测试

RewriteRule ^index/page/([^/.]+)$ index.php?page=$1 [L,QSA,NC]

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

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