htaccess rewrite log to multiple php files - apache

I need help in solving the issue with my htaccess rewrite for multiple php file. No matter what I do the the last condition of vod movie is not working and always point to the first php file new.php . The first three are working fine because they point to same file. I have read in here that they shouldn't be ambiguous but I don't know how to do it or solve it. Please help me thanks.
RewriteEngine ON
RewriteBase /
RewriteCond %{HTTP_HOST} ^test\.com$ [NC]
RewriteRule ^live/([^/]*)/([^.]*)/([^/]*)\.m3u8/?$ new.php?code=$1&c=$3&type=m3u8 [NC,L]
RewriteCond %{HTTP_HOST} ^test\.com$ [NC]
RewriteRule ^live/([^/]*)/([^.]*)/([^/]*)\.ts/?$ new.php?code=$1&c=$3&type=ts [NC,L]
RewriteCond %{HTTP_HOST} ^test\.com$ [NC]
RewriteRule ^([^/]*)/([^.]*)/([^/]*)?$ new.php?code=$1&c=$3 [NC,L]
RewriteCond %{HTTP_HOST} ^test\.com$ [NC]
RewriteRule ^movie/([^/]*)/([^.]*)/([^/]*)\.mp4/?$ /vod.php?code=$1&c=$3 [NC,L]

Could you please try following, based on your shown samples only. Please do clear your browser cache before testing URLs.
RewriteEngine ON
RewriteBase /
RewriteCond %{HTTP_HOST} ^test\.com$ [NC]
RewriteRule ^live/([^/]*)/([^/]*)/([^.]*)\.m3u8/?$ new.php?code=$1&c=$3&type=m3u8 [NC,L]
RewriteCond %{HTTP_HOST} ^test\.com$ [NC]
RewriteRule ^live/([^/]*)/([^/]*)/([^.]*)\.ts/?$ new.php?code=$1&c=$3&type=ts [NC,L]
RewriteCond %{HTTP_HOST} ^test\.com$ [NC]
RewriteRule ^movie/([^/]*)/([^/]*)/([^/]*)/([^.]*)\.mp4/?$ vod.php?code=$1&c=$3 [NC,L]
RewriteCond %{HTTP_HOST} ^test\.com$ [NC]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ new.php?code=$1&c=$3 [NC,L]

Related

.htaccess - Redirect domain/lang/ to subdomain for each language

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]

.htaccess 301 redirect not working correctly

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]

htaccess to write URL

I am trying to rewrite URL for users using htaccess file so that users can easily remember and make sure address bar stay cool.I accomplished to rewrite -
Rewrited URL
www.mysite.com/index.php?profile=2345
Actual URL wanted
www.mysite.com/profile/2345
.htaccess
RewriteRule ^profile/([0-9]+)/?$ index.php?profile=$1 [NC,L]
Unable to
**1. Multiple **
www.mysite.com/profile=2345&a=65&b=34&c=7&d=54
into
www.mysite.com/profile/2345/a/65/b/34/c/7/d/54
2. Is it possible to go further like?
profile.mysite.com/2345/a/65/b/34/c/7/d/54
1.
RewriteRule ^profile/([0-9]+)/a/([0-9]+)/b/([0-9]+)/c/([0-9]+)/d/([0-9]+)/?$ index.php?profile=$1&a=$2&b=$3&c=$4&d=$5 [NC,L]
2.
RewriteCond %{HTTP_HOST} ^profile\.mysite\.com$
RewriteRule ^([0-9]+)/a/([0-9]+)/b/([0-9]+)/c/([0-9]+)/d/([0-9]+)/?$ index.php?profile=$1&a=$2&b=$3&c=$4&d=$5 [NC,L]
3.
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com$
RewriteRule ^([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/?$ index.php?%1=$1&$2=$3&$4=$5&$6=$7&$8=$9 [NC,L]
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com$
RewriteRule ^([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/?$ index.php?%1=$1&$2=$3&$4=$5&$6=$7 [NC,L]
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com$
RewriteRule ^([0-9]+)/([abcd])/([0-9]+)/([abcd])/([0-9]+)/?$ index.php?%1=$1&$2=$3&$4=$5 [NC,L]
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com$
RewriteRule ^([0-9]+)/([abcd])/([0-9]+)/?$ index.php?%1=$1&$2=$3 [NC,L]
RewriteCond %{HTTP_HOST} ^([a-z]+)\.mysite\.com$
RewriteRule ^([0-9]+)/?$ index.php?%1=$1 [NC,L]

Need help removing special characters rewrite htaccess

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]

getting htaccess rewrite rules to rewrite only specific urls

I only want to rewrite this specific url:
http://www.website.co.uk/php/project.php?project=anythingHere
to
http://www.website.co.uk/php/project/anythingHere
this works fine but when I go to http://www.website.co.uk/php/project/anythingHere
it has changed all the links as well (style sheets, javascript, hyperlinks... things I don't want to change). for example:
http://www.website.co.uk/php/index.php
to
http://www.website.co.uk/php/project/index.php
This is what I have already
RewriteEngine On
RewriteCond %{HTTP_HOST} ^website.com\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.website.com\.co\.uk$
RewriteRule ^clients$ "http\:\/\/website.com\.co\.uk\/billing\/index\.php" [R=301]
RewriteRule ^project/([^/]*)$ /php/project.php?project=$1
Can you try this code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?website\.co\.uk$ [NC]
RewriteRule ^clients/?$ http://website.co.uk/billing/index.php [NC,L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(php/project)\.php\?project=([^\s&]+) [NC]
RewriteRule ^ /%1/%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(php/project)/([^/]+)/?$ /$1.php?project=$2 [L,QSA,NC]