我是新人,我学习.htaccess
。我想自定义我的网址
从
index.php?page=mobile
至
index/page/mobile
我使用了这段代码,但它不起作用:
RewriteEngine on
RewriteRule ^index/([0-9]+)/?$ index.php?page=$1 [NC,L] # Handle product requests
和
RewriteEngine on
RewriteRule ^index/([^/.]+)/?$ index.php?page=$1 [L]
答案 0 :(得分: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]
这样,您就可以在网页上显示http://domain.com/index/page/mobile
的网址。
答案 1 :(得分:2)
尝试该代码:
RewriteEngine on
RewriteBase /
RewriteRule ^index/page/([^/.]+)/?$ index.php?page=$1 [L,QSA,NC]
答案 2 :(得分:0)
这应该有用 - 虽然没有经过测试
RewriteRule ^index/page/([^/.]+)$ index.php?page=$1 [L,QSA,NC]