[英]how to redirect with htaccess without changing the URL in browser
I have a normal dynamic url and i want it to make SEO friendly as below 我有一个正常的动态网址,我希望它使SEO友好,如下所示
my URL is 我的网址是
domain.com/search.php?v1=mobiles&v2=nokia
to 至
domain.com/search/mobiles/nokia
please help 请帮忙
You need to use .htaccess file to do this rewriting action without chenging the url in browser, Try the below code 您需要使用.htaccess文件执行此重写操作,而无需在浏览器中查找url,请尝试以下代码
RewriteEngine On #remove this if already added
RewriteRule ^search/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ search.php?s1=$1&s2=$2 [NC,L]
I would do this: 我会这样做:
RewriteEngine On #if not already on.
RewriteCond %{REQUEST_FILENAME} !-f #only if it is not calling a file that actually exists
RewriteCond %{REQUEST_FILENAME} !-d #only if it is not calling a directory that actually exists.
RewriteRule ([a-z0-9]+)(/*)([a-z0-9]*)(/*)([a-z0-9]*)(/*) search.php?v1=$1&v2=$3 [L,NC,QSA]
This will work even if you only go to /mobile/ (assuming your search.php can handle that.) 即使您仅转至/ mobile /(假设search.php可以处理该问题),该方法也将起作用。
HTH 高温超导
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.