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

Zoh*_*tar 1 php .htaccess

我是新人,我学习.htaccess.我想从我的自定义URL index.php?page=mobileindex/page/mobile

我使用了这段代码,但它不起作用:

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

RewriteEngine on
RewriteRule ^index/([^/.]+)/?$ index.php?page=$1 [L]
Run Code Online (Sandbox Code Playgroud)

anu*_*ava 6

这条规则应该有效:

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]
Run Code Online (Sandbox Code Playgroud)

这样您就可以http://domain.com/index/page/mobile在网页上找到网址了.