: How to fix .htaccess - redirect http://408.111.1111.domain.us/ to http://domain.us/index.php?w=408.111.1111 We want to use mod_rewrite and .htaccess to do a redirect. How do we redirect http://408.111.1111.domain.us/
We want to use mod_rewrite and .htaccess to do a redirect. How do we redirect 408.111.1111.domain.us/ and 408.111.1111.domain.us/ to domain.us/index.php?w=408.111.1111 ? If the original URL has a dash in place of the periods, or no periods in front of '.domain.us', it works fine. Wildcard domains work fine.
Here is our .htaccess file:
RewriteEngine On
Options +Followsymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{REQUEST_FILENAME} !^.*/images/.*$
RewriteCond %{REQUEST_FILENAME} !^.*/uploads/.*$
RewriteCond %{HTTP_HOST}<>%{REQUEST_URI} ^([^.]+).rmwy.us(:80)?<>/([^/]*) [NC]
RewriteCond %1<>%3 !^(.*)<>1$ [NC]
RewriteRule ^(.*)$ - [E=BLOGUSER:%1]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^$ /index.php?w=%1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^page([0-9]+)/([^/]+)?$ /index.php?w=%1&page= [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^profiles/([^/]+)/([^/]+)?$ /profile.php?u= [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^profiles/?$ /profile.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^albums/([^/]+)/([^/]+)?$ /album.php?u= [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive/(.*)/(.*)/([^/]+)?$ /archive.php?w=%1&y=&m= [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive.php/(.*)/(.*)/([^/]+)?$ /archive.php?w=%1&y=&m= [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive/(.*)/([^/]+)?$ /archive.php?w=%1&y= [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive.php/(.*)/([^/]+)?$ /archive.php?w=%1&y= [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive/([^/]+)?$ /archive.php?w=%1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^archive.php/([^/]+)?$ /archive.php?w=%1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^friends/([^/]+)?$ /friends.php?w=%1 [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^friends.php/([^/]+)?$ /friends.php?w=%1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/friends/page([0-9]+)/([^/]+)?$ /friends.php?w=&page= [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^([0-9]+)/([^/]+).html$ /entry.php?w=%1&e_id= [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^([0-9]+)/([^/]+)?$ /entry.php?w=%1&e_id= [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^&([^/]+)?$ /index.php?w=%1& [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^([^/]+)/([^/]+)?$ /index.php?w=%1&category= [L]
RewriteCond %{ENV:BLOGUSER} ^(.+)$
RewriteRule ^([^/]+)/page([0-9]+)/([^/]+)?$ /index.php?w=%1&category=&page= [L]
More posts by @Kaufman445
1 Comments
Sorted by latest first Latest Oldest Best
My poor eyes are too tired to read through your .htaccess file but regarding your basic request for code that rewrites xyz.domain.us to domain.us/index.php?w=xyz, it would look something like this:
RewriteCond %{HTTP_HOST} !^domain.us [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} (www.)?([0-9.]+).domain.us
RewriteRule ^.*$ domain.us/index.php?w=%2 [L,R=301]
You could then expand this to cater for different file paths (e.g. /friends/xyz) by using different RewriteRules.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.