joomla htaccess RewriteRule issue - .htaccess

i have a redirect in my htaccess which works perfectly in joomla before i swicth on SEF URLS
RewriteRule ^m/(.*) /index.php?option=com_seemail&view=mail&guid=$1&itemid=102
however when i switch on SEF URLS then it no longer works - im directed to /home/uncategorised/welcome instead
this is my htaccess :
RewriteEngine On
RewriteRule ^m/(.*) /index.php?option=com_seemail&view=mail&guid=$1&itemid=102
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^apply$ /index.php?option=com_loans&view=apply&Itemid=102 [R=301,L,QSA]
RewriteBase /
DirectoryIndex index.php
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
can anyone help please ?

RewriteRule ^apply$ /index.php?option=com_loans&view=apply&Itemid=102 [R=301,L,QSA]
based on the above line of code, if there is nothing after "apply" in the url, it should redirect to /index.php?option=com_loans&view=apply&Itemid=102 and stop looking at other rules for the said case.
As you said it is redirecting that means it is working.
Can you manually open the <yourdomain.com>/index.php?option=com_loans&view=apply&Itemid=102
If it opens and the url is sef, copy the sef url after the domain and replace /index.php?option=com_loans&view=apply&Itemid=102 with that in the RewriteRule.
May be that should work.

Related

.htaccess rewrite portion of URL

I have two requirements:
I want to rewrite component/testcomp in URL to just comp.
https://www.website.com/component/testcomp should look as:
https://www.website.com/comp in URL.
All requests coming fo website.com should be 301 redirected to https://www.website.com
Below is the content of my .htaccess file:
IndexIgnore *
Options +FollowSymlinks
Options -Indexes
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
RewriteBase /
RewriteCond %{HTTP_HOST} ^website\.com$ [NC]
RewriteRule ^(.*)$ https://www.website.com/$1 [R=301,L]
How can I do so? I tried adding Rewrite Rule but it is not working. Let me know the Rewrite rule & where should I place it.
To rewrite "/component/testcomp" to just "comp", I think you have to flag it with R, or use R=301 to make it a permanent. I have a feeling you may have to adjust additional rules, however.
RewriteRule ^component/testcomp/(.*)$ /comp/$1 [L,R]
or to make it permanent:
RewriteRule ^component/testcomp/(.*)$ /comp/$1 [L,R=301]
Try the following:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /component/test(comp)(\S*) [NC]
RewriteRule ^ /%1 [R=301,L,QSA]
and then,
RewriteRule ^comp(.*)$ /component/testcomp$1 [QSA,NC,L]

.htaccess redirect without changing URL

The content is currently accessed through this URL: http://website.de/de/angebot/llm
On our brochures we would like to print the short URL for our customers, so the above URL can be accessed when entering short URL like this: http://website.de/llm
This is what I got so far:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/llm http://website.de/de/angebot/llm [QSA,NC,L]
It works in the way of redirecting clients. So when they enter short URL they are properly redirected to long URL.
What I would like if it is possible that URL doesn't change to the long one, but stays short in their browsers.
This is the full .htaccess
# Exploits
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
#Custom
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?llm de/angebot/llm [NC,L]
# Joomla
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
With joomla you could create a redirect within joomla that would help you achieve this.
You could as well create a menu item as an alias to your long url.
In .htacess I would try something like:
RewriteCond %{HTTP_HOST} ^yourdomain.com/llm$ [NC]
RewriteRule ^$ http://www.yourdomain.com/de/angebot/llm [R=301,L]

.htaccess won't let me enter a subfolder

I have joomla in a hosting, and it is working fine.
But I want to create a small webservice for an app, so I created a subfolder in my root folder to have access like this: www.mydomain.com/myfolder
The problem is, the .htaccess is automatically redirecting me to the joomla index. I don't have experience with the .htaccess configuration at all. I have been reading some tutorials, but every time I change something, the joomla stops working properly.
Here is my htaccess file:
rewriterule ^component/users/(.*)$ index.php?option=com_comprofiler&task=login [L]
rewritecond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
rewritecond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
rewritecond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
rewritecond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
rewriterule .* index.php [F]
rewriterule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
rewritecond %{REQUEST_URI} !^/index\.php
rewritecond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
rewritecond %{REQUEST_FILENAME} !-f
rewritecond %{REQUEST_FILENAME} !-d
rewriterule .* index.php [L]
Creating a subdomain is not an option (I only have access to the ftp)
thanks
Right after rewritecond %{REQUEST_URI} !^/index\.php, add:
RewriteCond %{REQUEST_URI} !^/myfolder/
That should exclude any request for /myfolder/ from getting routed to joomla's index.php file.

Joomla .htaccess

I need a working RewriteRule to get rid of the /index.php/category/ part of my url(s).
bruteforce.tv/index.php/streams/shinigamily
bruteforce.tv/index.php/streams/cash
bruteforce.tv/index.php/streams/blacktigrex
bruteforce.tv/index.php/streams/viktorwwe
TO
bruteforce.tv/shinigamily
bruteforce.tv/cash
bruteforce.tv/blacktigrex
bruteforce.tv/viktorwwe
I'm not used to it with working with a htaccess file so I apologize for being completely unresourceful.
This is my current htaccess file with the not working RewriteRule ^streams/(.*)/?$ /$1 [L,NC,R]
Options +FollowSymLinks
## Mod_rewrite in use.
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteBase /
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^streams/(.*)/?$ /$1 [L,NC,R]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
Use Joomla's built-in feature to remove /index.php (under global config > site)
RewriteRule ^streams/(.*)$ http://bruteforce.tv/$1 [R=301,L]

Using Subdirectory as subdomain in htaccess

I am trying to point a subfolder on my site as a subdomain. for example, i want to turn www.domain.com/test to test.domain.com. I already have some rewrites in htaccess done by developers that we used earlier in the site building process, and I'd like to be able to add this line without interfering with those.
I've tried dozens of answers to this issue i found across the net, but none of them seemed to work and i'm not sure if it's due to my lack of knowledge of this language or if there's a conflict with something else.
The latest lines I tried are:
RewriteCond %{HTTP_HOST} !^www.domain.tv
RewriteCond %{HTTP_HOST} ([^.]+).domain.tv
RewriteRule ^(.*)$ /var/www/www.domain.tv/test%1
This is my current htaccess file:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#RewriteCond %{HTTP_HOST} !www\.domain\.tv$ [NC]
#RewriteCond %{HTTP_HOST} ^(.+)\.domain\.tv$ [NC]
#RewriteRule .* index.php?option=com_contushdvideoshare&view=player&Itemid=33 [L]
RewriteCond %{REQUEST_URI} ^/album\/t\/([a-zA-Z0-9]+) [NC]
RewriteRule ^album/t/(.*) index.php?option=com_usermenu&task=directdownload&id=$1&type=one$
RewriteCond %{REQUEST_URI} ^/album\/([a-zA-Z0-9]+) [NC]
RewriteRule ^album/(.*) index.php?option=com_usermenu&task=directdownload&id=$1 [L]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F]
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} (/[^.]*|\.(php|html?|feed|pdf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
Can anyone help me here?
Try:
RewriteCond %{HTTP_HOST} !^www.domain.tv [NC]
RewriteCond %{HTTP_HOST} ([^\.]+).domain.tv [NC]
RewriteRule ^(.*)$ %1/$1 [L]
Subdomains aren't so easy to set up. You will need to configure your server before. More informations here : Create subdomains on the fly with .htaccess (PHP)

Resources