WHMCS 7.2: RewriteRule doesn't work - .htaccess

Problem start when I upgraded WHMCS from 6.3 to 7.2. All my rewriterules working except this one:
RewriteRule ^en/$ index.php?language=english [NC,L,QSA]
I can open page www.example.com/index.php?language=english wthout problem.
But when I try to open www.example.com/en/ I get 404 error
WHMCS has poor language handling and this was my way fixing it. It used to work great under v6.3 but not under v7.2.
I have asked on WHMCS forum but had no answer. I asked WHMCS directly but they said this is third party modyfication and they not support that.
You are my last hope!

These rules worked for me:
# Redirects www.example.com/en/ to
# www.example.com/index.php?language=english
RewriteCond %{REQUEST_URI} en\/$
RewriteRule ^en/$ index.php?language=english [NC,L,QSA]
# Redirects sub pages: www.example.com/en/serverstatus.php
# to correct URL www.example.com/serverstatus.php
RewriteCond %{REQUEST_URI} en\/(.*)$
RewriteRule ^en/(.*) $1 [QSA,L]

Related

.htaccess rule help in a plex non-windows hosting environment

I'm having trouble writing a rule for .htaccess which will redirect HTML to PHP. I'm using 302 until I get it to work right - then I'll change to a 301. I found several postings that describe this, but I am having problems - possibly because I'm running a hosting package, and each client is in a virtual/subfolder (sorry for poor description of hosting environment).
The rule I am using is
...
RewriteEngine on
RewriteRule ^(.*).html$ $1.php [R=302]
...
When I try to go to https://dmcelebratealife.com/index.html I get a 404 message saying:
https://www.dmcelebratealife.com/var/www/vhosts/dmcelebratealife.com/public_html/index.php
I added the following and it seemed to work for me.
RewriteEngine on
RewriteRule ^(.*)\.html$ /$1.php [R=302]
This works for me and is domain-independent.
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(?!.+\.\w{2,4})(.+)$ $1.php [L]
RewriteCond %{DOCUMENT_ROOT}/$1.html -f
RewriteRule ^(?!.+\.\w{2,4})(.+)$ $1.html [L]
The first two redirect to the php file if it exists. If it doesn't then the second two will try for an HTML file.
Note it doesn`t use a 302 as you don't want to tell the user what you are doing. This does an internal redirect.
This means that if the user types in
https://www.example.com/test
it will remain in the URL box, but the following file will be executed
https://www.example.com/test.php

Language redirection with mod_rewrite

I'm totally clueless when it comes to mod_rewrite, so I'll be glad to get any help. I just want Apache to redirect my homepage according to the detected country language. My PHP is auto-translating in multiple languages and I'm trying to avoid multiplying the same exact Site to subdomains and domains because of SEO - but looks like Google is not so advanced yet, giving no other choice.
e.g.
mysite.com to:
mysite.com/index.php?lang=nl for holland
mysite.com/index.php?lang=fr for france
and for no specified country code just to:
mysite.com/index.php?lang=be
mysite.com/?lang=nl wwould also be fine
I'll also be happy to hear a better suggestion.
I tried the following with no succes
RewriteCond %{HTTP:Accept-Language} ^nl[NC]
RewriteRule ^index\.html /index\.php?lang=nl [QSA,NC,L]
RewriteCond %{HTTP:Accept-Language} ^fr[NC]
RewriteRule ^index\.html /index\.php?lang=fr [QSA,NC,L]
I'm just getting a server error - Couldn't find an exact case that could help
Try with:
RewriteCond %{HTTP:Accept-Language} ^(nl|fr) [NC]
RewriteRule ^(index\.html)?$ /index.php?lang=%1 [QSA,NC,L]
RewriteRule ^(index\.html)?$ /index.php?lang=be [QSA,NC,L]

Redirect Specific non-existing URL to an existing

I have a simple need to redirect:
mypage.com/myurl (which doesn't not exist; meening that returns a 404 error)
To
mypage.com/newurl/myurl (which is an exitsing page with content).
I saw a tons of forum post about this, but didn't find an awnser. I tried lot of thinks but with internal server error, infinitive loops etc.
Please note that I have a www to non www permanent redirect, like this:
RewriteCond %{HTTP_HOST} ^www\.mypage\.si [NC]
RewriteRule ^(.*)$ http://mypage.si/$1 [L,R=301]
UPDATE:
I will be specific:
This URL doesn't exist: http://domodom.si/sl/nepremicnine
and needs to be redirected here: http://domodom.si/sl/nepremicnine/nepremicnine-ponudba
Hope this will offer more insights about the problem.
Thanks
assuming mod_rewrite
RedirectPermanent /myurl/ mypage.com/newurl/myurl
Add this to your .htaccess file
RewriteBase /
RewriteRule ^(.*)$ newurl/$1 [NC,L]
you may want to try implementing the answer of nwellnhof in this thread.. it worked for me..

Redirect all subdomains using .htaccess

What I want to achieve is to redirect any subdomain.mydomain.info to mydomain.info/subdomain using a 301 so that the visitor still sees subdomain.mydomain.info.
After some research I found that I had to set wildcard in my A-Record, did that. Than I went on to create a .htaccess. Below is my entire .htaccess.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.info [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.domain\.info [NC]
RewriteRule ^(.*)$ /%1/$1 [L]
When I open subdomain.mydomain.info where I know that mydomain.info/subdomain is an existing folder I only get a message telling me that the domain "subdomain.mydomain.info" is unavailable.
My webspace is running a Confixx panel, just if that helps.
What could be going wrong here?
At this point I am guessing that some configuration outside the .htacces need to be made, but no idea what and where.
BIG EDIT:
Revisiting this. Turned out I had to talk to my provider to get some things set up correctly. Still trying to figure this our though.
Current situation: the .htaccess from above gives me a 500. Putting in an R, als was suggested in the comments, will redirect "sd.domain.info" to "domain.info/sd/sd/sd/sd" and result in an error by my browser. The browser says "There is redirect on this page" and give me the option to load it again. The version suggested by Al Kafri Firas also gives me a 500. When I remove the .htaccess any "subdomain.doamin.info" gets redirected to "domain.info" with the URL being changed in the head of my browser.
Still looking to get this working....
Revert all changes you made to your A-Record and use this rules
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.info$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.example\.info$ [NC]
RewriteRule /%2%{REQUEST_URI} [PT,L]

htaccess - Rewrite rule and/or condition to fix totally different discontinued or incorrect incoming link

Well, I am stuck again. Two days of reading and again, found some close solutions but, nothing fits and all my experiments failed.
This is a continuation of my question:
here at stackoverflow
The 4 rules below take my incoming links:
http://somedomain.com/getme.pl?dothis=display&partnum=1234567
and beatifies it.
Also allows users to use the beatified version right in address bar:
http://somedomain.com/1234567
Here are my working rules:
RewriteRule ^([\s]*)$ /getme.pl [L] ## in case there is a space or nothing.
RewriteRule ^([0-9]*)$ /getme.pl?dothis=display&partnum=$1&rewrite [L]
RewriteCond %{QUERY_STRING} partnum=([0-9]*)$
RewriteRule (.*) /%1? [L,R=301]
Works great but, I discovered there are some old links to the site out there:
http://somedomain.com/oldversion.php?id=123456789
And
http://somedomain.com/oldversion.php?r=86this&id=123456789
I would like to just grab the id=[0-9] and integrate it with my working rules.
I suppose, the rule would be inserted between the second and third rules above.
I tried various attempts (about 100!) like:
RewriteRule ^(oldversion\.php)?([a-z]{1})=([a-z0-9]*)&([a-z]{2})=([0-9]*)$ /$4? [L]
RewriteRule ^(oldversion\.php)?([a-z]{2})=([0-9]*)$ /$3? [L]
As you see, two days of reading and nothing is sinking in for me.
I tried several variations of the working rules I already have as well, to no avail.
Can't I just get the 123456789 off of the outdated .php urls somehow and stick it in my existing rules?
Thanks for your help and explaining down to my level co, I just might be able to understand...
Put this at the end of your .htaccess file:
RewriteCond %{QUERY_STRING} id=([^&]+)(&|$) [NC]
RewriteRule ^oldversion\.php$ /%1? [L,R=301,NC,NE]
For a URI of /oldversion.php?r=86this&id=123456789 it will internally redirect to /123456789
Remember RewriteRule just matches your URI and it cannot match your QUERY_STRING.

Resources