Reputation: 885
I've added a mobile version which redirects automatically with MobileDetect.php.
After redirect the URL is: /index.html?mpage=home.
For example, when the Desktop version URL is /medical-studies
, the mobile is /index.html?mpage=medical-studies
.
I want to use mod_rewrite or other mod if possible that the mobile version will show the same desktop URL;
I mean change
/index.html?mpage=X
to
/X
Upvotes: 0
Views: 206
Reputation: 1364
Try this:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} iPhone [OR]
RewriteCond %{HTTP_USER_AGENT} Android [OR]
RewriteCond %{HTTP_USER_AGENT} Blah...
RewriteRule ^(.*)$ index.html?mpage=$1 [L]
If User-Agent
matches some of mobile agents, mod_rewrite internally redirects the access to index.html with original path added. (URL shown in User-Agents does not changed.)
Note
RewriteCond
should be replaced with proper conditions.REDIRECT_QUERY_STRING
instead of QUERY_STRING
.Upvotes: 1