here is my code in my .htaccess file:
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteCond %{HTTP_HOST} ([^.]+)\.domain\.com [NC]
RewriteRule ^/?$ /user/profile.php?name=%1 [L]
here is what it does:
if i visit test.domain.com, it will show the contents (not redirect) of domain.com/profile.php?name=test.
but if i type: test.domain.com/login, it will show the contents of the page: domain.com/login.
Question: why is that? how can i turn that off? thanks
Hope this will work, working fine on my end.
RewriteCond %{HTTP_HOST} !^www\.domain\.in
RewriteCond %{HTTP_HOST} ^test\.dmmain\.in [NC]
RewriteRule ^$ http://test.domain.in/user/profile.php [L,QSA]
Related
I've been struggling with this for weeks and I can't get to the solution, I have to make a redirect in .htaccess of a multi-language website with all its pages following the same structure but with a subdomain for each language. In the following way that is valid for http as https:
domain.es/es/allpages to es.subdomain.com/allpages
domain.es/pt/allpages to pt.subdomain.com/allpages
domain.es/de/allpages to de.subdomain.com/allpages
domain.es/fr/allpages to fr.subdomain.com/allpages
domain.es/en/allpages to eu.subdomain.com/allpages
Any ideas?
I have tried the following but not sure if it is correct:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/es/(.*)$
RewriteRule ^(.*) https://es.subdomain.com/%1 [R=301,NC]
RewriteCond %{REQUEST_URI} ^/pt/(.*)$
RewriteRule ^(.*) https://pt.subdomain.com/%1 [R=301,NC]
RewriteCond %{REQUEST_URI} ^/fr/(.*)$
RewriteRule ^(.*) https://fr.subdomain.com/%1 [R=301,NC]
RewriteCond %{REQUEST_URI} ^/de/(.*)$
RewriteRule ^(.*) https://de.subdomain.com/%1 [R=301,NC]
RewriteCond %{REQUEST_URI} ^/en/(.*)$
RewriteRule ^(.*) https://eu.subdomain.com/%1 [R=301,NC]
Thanks a lot!!!!
Based on your shown samples, could you please try following. Please make sure you clear your browser cache before you test your URLs.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.es$ [NC]
RewriteRule ^(es|pt|de|fr|en)/(.*)/?$ http://$1.subdomain.com/$2 [NE,R=301,NC,L]
I'm trying to setup an .htaccess file to redirect old urls which I have REMOVED the pages from the server (not sure if this is the problem). I'm trying to redirect the pages to the new page which has the same content. Can anyone tell me why this doesn't work? (I believe it should) followed several online guides.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com/wheels_landing_page.php [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com/wheels_landing_page.php [NC]
RewriteRule ^(.*)$ http://example.com/wheelsLanding.php/$1 [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^example.com/dealerships.php [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com/dealerships.php [NC]
RewriteRule ^(.*)$ http://example.com/contact.php/$1 [L,R=301,NC]
Try with:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^wheels_landing_page\.php(.*)$ http://example.com/wheelsLanding.php$1 [L,R=301,NC]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^dealerships\.php(.*)$ http://example.com/contact.php$1 [L,R=301,NC]
i have this link
http://localhost/fukhtaccess
and i want redirect the link to http://server.localhost/index.php with GET params.
this is my htaccess, but don't work and not possibile test with some error for debug (thanks apache foundation!!!)
RewriteEngine On
RewriteCond %{HTT_HOST} ^localhost$
RewriteCond %{REQUEST_URI} fukhtaccess
RewriteRule (.*) http://server.localhost/index.php [QSA,L]
You have a typo: change HTT_HOST to HTTP_HOST.
Also, your second RewriteCond just complicates things unnecessarily. Do this instead:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost$
RewriteRule fukhtaccess http://server.localhost/index.php [QSA,L]
better, this work fine
RewriteEngine On
RewriteCond %{HTTP_HOST} ^localhost [NC]
RewriteCond %{REQUEST_URI} fukhtaccess$ [NC]
RewriteRule (.*) http://server.localhost/index.php [QSA,L]
Struggling with a 301 redirect in htaccess after changing my links on my blog.
I have the following code in htaccess today:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^.*$ http://example.com%{REQUEST_URI} [R=301,L]
RewriteRule ^sitemap.xml$ sitemap.php [L]
Rewriterule ^blog/(.+)/(.+).html$ ./blog/view/blog.php?page=$1&mode=$2 [NC]
Rewriterule ^blog/(.+).html$ ./blog/blog.php?page=$1 [NC]
Rewriterule ^blog/(.+)/$ ./blog/view/blog.php?page=$1 [NC]
Rewriterule ^blog/$ ./blog/blog.php [NC]
RewriteCond %{REQUEST_FILENAME} !-f
Rewriterule ^blog/(.+)/(.+)$ ./blog/view/blog.php?page=$1&mode=$2 [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^blog/(.+)$ ./blog/blog.php?page=$1 [NC]
The problem is that I´ve now in php converted special characters like 'åäö' to 'aao' but the old links to my old posts has no redirect to the new links.
Can someone please help me out here.
Here is an example of a simple 301 Redirect that I based the following code from.
Here is an example of redirection based on extension to fit your requirement.
RewriteEngine On
RewriteCond %{REQUEST_URI} .html$
RewriteRule ^blog/(.*).html$ /blog/blog.php?page=$1[R=301,L]
Need a little help getting the following rule working:
RewriteCond %{HTTP_HOST} ^asset.*.domainone\.com [NC,AND]
RewriteCond %{REQUEST_URI} !^/FILE/.* [NC]
RewriteRule ^(.*)$ "http://domaintwo\.com/$1" [L]
For requests coming to this server with a domain of 'asset(anything).domain.com' which does not start with 'FILE', redirect to another server.
Thanks.
RewriteCond %{HTTP_HOST} ^asset.*?\.domainone\.com [NC]
RewriteCond %{REQUEST_URI} !^/FILE/.* [NC]
RewriteRule ^/(.*)$ http://domaintwo.com/$1 [R,L]