Mod_rewrite - redirect query string to homepage - url-rewriting

Can you help me redirect this url https://www.theholisticsanctuary.com/?s=%7Bsearch_term_string%7D to homepage using htaccess? I tried it using rank math redirect but no luck. I have tried this but Im afraid it is wrong.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^s=%7Bsearch_term_string%7D
RewriteRule ^https://www.theholisticsanctuary.com/? [R=301,L]
</IfModule>

You were close!
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^s=%7Bsearch_term_string%7D
RewriteRule ^(.*) https://www.theholisticsanctuary.com/$1 [R=301,L,QSA]
</IfModule>

Related

/public still appears in some URLs but not others after updating .htaccess file

I've updated my .htaccess in public_html root directory to try to remove /public from the URL
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
It works for some URLs but not others. I've cleared server & browser cache. Still no improvement.
I'm working with Laravel 5.7, PHP 7
Any help appreciated. If more info needed let me know and I'll do my best to provide it.
Cheers
Edit your .htaccess with this code. it might help
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
</IfModule>

.htacces for api rest and admin panel

I have a website in laravel with this .htacces and work fine for my admin panel
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
but now I wrote an APP in Ionic that consume an api rest from my website and I cant access the server but if change the .htaccess to this, work for the APP but not the website
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
</IfModule>
My error is “CAUTION: provisional headers are shown” and headers are not sent if I use the first .htacess.
I would like to know how to combine the two .htaccess, I tried this but doesn't work.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
</IfModule>

How to remove directory path form image url using htaccess?

http://example.com/abc/media
TO
http://example.com/media
How to set this URL with use of .htaccess?
Could you try:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ abc/$1 [L]
</IfModule>
If u using only for image. You can try with:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^.*/abc/media/(.*)$ http://%{HTTP_HOST}/media/$1 [L,R=301]
</IfModule>
RewriteCond %{REQUEST_URI} ^/abc/$
RewriteRule .* - [E=MAGE_RUN_CODE:aaa]
RewriteCond %{ENV:REDIRECT_MAGE_RUN_CODE} (.+)
RewriteRule .* - [E=MAGE_RUN_CODE:%1]
RewriteBase /abc/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /abc/index.php [L]/
This is my .htaccess file.
Now we need to remove /abc/ folder from image URL so we get all image URL from the Root directory.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^.*/abc/media/(.*)$ http://%{HTTP_HOST}/media/$1 [L,R=301]
</IfModule>
Already Try this but not working on my site.

Why my .htaccess in codeigniter is different

All of my .htaccess in codeigniter like this
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
But all tutorial .htaccess are like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I need help to remove index.php url in codeigniter.
Why should I replace all code .htaccess like tutorial said ?
Should you replace all code .htaccess like tutorial said ?
Yes! just in the root directory of your CodeIgniter project.
Why?
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
The CodeIgniter documentation says that by the rules given in .htaccess file, any HTTP request other than those for index.php, images, and robots.txt is treated as a request for your index.php file.
without these rules, for example, you'll have to access your login page like this
http://yourdomain.com/index.php/<controllerName>/login
with the rules in .htaccess file it's
http://yourdomain.com/<controllerName>/login

CodeIgniter frontend do not work

I bought a real estate cms written with CodeIgniter, i uploaded it to my hosting account, but when i try to access my url it doesn't show the frontend part.
I know there is a problem in url rewrite or something like this, if someone can help me, i'll be thankful
By the way the backend work as well (immonador.esy.es/admin/index.php) but the frontend (immonador.esy.es/index.php) dosen't work. This is my .htaccess file
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteBase /
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
Try this
<IfModule mod_rewrite.c>
RewriteEngine on
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteBase /
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

Resources