I have created a www.example.com
and m.example.com
. The m.example.com
resides inside the htdocs/m/
folder. I am using the below codes in the .htaccess
:
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} \s/+(.*?/)?(?:index)?(.*?)\.php[\s?] [NC]
RewriteRule ^ /%1%2 [R=302,L,NE]
#mobile
RewriteCond %{HTTP_HOST} ^m\.example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/m(/|$) [NC]
RewriteRule ^(.*)$ m/$1 [L]
# Resolve .php file for extension-less php urls
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ /$1.php [L]
Now,if users hit m.example.com/abc
and if the abc
files doesn’t exist, it will redirect users to the error page, as I have the below code on the .htaccess
code inside the htdocs/m/
folder
ErrorDocument 404 http://m.example.com/error
But now I want the users to be redirected to www.example.com/abc
instead, as abc
may be a valid file in the desktop version. Only if the files also doesn't exist in the desktop site, the users will be redirected to the error page.