Questions tagged [.htaccess]
Directory-level configuration file found mostly on Apache web servers
2,828
questions
2
votes
1
answer
33
views
How to match beginig of file name via htaccess
I am attempting to modifying my .htaccess file within a specific directory. If a web user attempts to find any file in this directory that may be named like the following options, I want them to be ...
0
votes
0
answers
31
views
Getting to testing site when typing dev.example.de (subdomain for testing basically)
I want to get directed to my testing site when I type dev.example.de. The directory already exists, but everytime I type dev. I get directed to the production page (without dev). I've been trying to ...
0
votes
0
answers
67
views
How to block some bots in .htaccess but except access robots.txt?
I've blocked some bad bots using .htaccess.
For example:
SetEnvIfNoCase User-Agent "^bot1" bots
SetEnvIfNoCase User-Agent "^bot2" bots
SetEnvIfNoCase User-Agent "^bot3" ...
0
votes
1
answer
26
views
Excluding all files that begin with X in .htaccess maintenance mode redirect
Here's my maintenance mode redirect:
# MAINTENANCE-PAGE REDIRECT
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^0\.0\.0\.0
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|...
0
votes
1
answer
28
views
.htaccess to get the list of ip from a file or directories of file
I'm blocking certain spammers/bots from accessing my website via IP addresses, but I have around 3 directories (/var/www/directory1, /var/www/directory2, /var/www/directory3).
Every time I want to ...
0
votes
0
answers
43
views
HTTPS redirect not working
My old domain is paradise-greece.com and I am forwarding to my new website paradisemykonos.com via Godaddy dashboard (301). Problem is, Google crawled https://www.paradise-greece.com/ which doesn't ...
0
votes
0
answers
28
views
Confirm these 301 redirects are correctly setup in my htaccess file
i have in my root directory my english page and in subdirectory folder arabic page but the rule but as per https://htaccess.madewithlove.com/ :
RewriteCond %{HTTP_HOST} ^arianamedicaretour\.com$ [NC]
...
0
votes
1
answer
35
views
how to redirect entire my website in multilingual html website
i have a multilingual website, Arabic and English, my English pages its in rood directory and Arabic pages its in folder name ar; but i got my auditing report that; Search engines see
www....
1
vote
1
answer
61
views
Creating a .htaccess in a subdirectory causes rewrite rules in higher level .htaccess to stop working
Sorry if this has been asked/answered before, but I was not able to find an answer to this particular problem.
If I create a .htaccess file with a simple rewrite rule, that rule works. If I create ...
0
votes
0
answers
36
views
MAC binding specific Sub Domain with HTACCESS [duplicate]
I want to bind a specific MAC to a specific subdomain address. I am now using this code for a specific IP. But now I want to use a specific MAC address.
RewriteEngine On
ErrorDocument 403 /403.html
...
-1
votes
1
answer
167
views
How to block unrecognized hostnames in .htaccess (A Domain Name I Don't Recognize Is Redirecting To My Site)
I'm using Dedicated IP on a shared linux server... At first, I saw that an unfamiliar hostname displayed my own website like a mirror. I scanned the A records of this site to investigate what was ...
1
vote
1
answer
116
views
.htaccess to normalize requests to files with or without extension to URL without extension: $1(\.html?) --> $1
This is a followup question
My intended .htaccess ruleset has overall been achieved.
See that file in its current form quoted below.
Remaining problem: One ruleset yet not working
Goal: Normalize ...
0
votes
0
answers
30
views
Problems with .htaccess
I'm new to hosting a server. Let's say my domain is wordpress.com. I have a LAMP-server on Ubuntu Server 23.10. It runs a local wordpress server and is working perfectly. I want to restrict access to ...
1
vote
2
answers
259
views
.htaccess files directive only matching when I'm checking the same folder
I've got a server set up where I want a specific PHP file to be readable via the browser, but I want access to be denied to the rest of the PHP files. So I put this .htaccess in the server root:
<...
1
vote
2
answers
157
views
Apache Rewrite Engine redirect all request to index.php
I have a PHP web application on a Apache Web Server.
The path to to web application on the Server is: /var/www/html/intern/organisation/example_app
The URL to the web application is:
https://www....
0
votes
0
answers
249
views
htaccess to stop Host Header Injection
I have one application hosted on XAMPP, my application url is https://abc.example.com/pps/prd/, i have htaccess file at pps/prd/, with following code to stop Host header injection
RewriteEngine On
...
0
votes
1
answer
132
views
htaccess don't rewrite to index for any URL
My htaccess don't rewrite to index HTML
https://world-of-easy-decisions.com/login
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# Exclude rewriting for URLs starting with /main/
...
0
votes
1
answer
33
views
Content negotiation, send webp request to Symfony when webp file does not exist
On Apache Httpd 2.4, I know that from a .htaccess file I can do this
RewriteCond %{HTTP_ACCEPT} image/webp
RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
RewriteRule (.+)\.jpg$ $1.webp [T=image/webp]
in ...
0
votes
0
answers
87
views
Block request via htaccess if host contains X
I have many bots that are accessing my site, and since they use mostly amazon web services to spam with the requests, in the logs it looks like that:
ec2-47-128-60-90.ap-southeast-1.compute.amazonaws....
0
votes
0
answers
193
views
Error using nonce in .htaccess Content-Security-Policy (CSP)
I am attempting to use Content-Security-Policy nonce and its generating an error.
The Error via console.log:
Refused to apply inline style because it violates the following Content Security Policy ...
0
votes
0
answers
100
views
How to redirect url included string in htaccess file?
I need a rewrite rule in htaccess file. I have the following URL:
https://example.com/https%3A%2F%2Fwww.another.com%2Fcatalog%2F%3Fq%3Dhello+friend
I need to redirect it to the URL output excatlly ...
0
votes
2
answers
224
views
IF statement based on comparison with %{REQUEST_URI} in .htaccess doesn't work
I'm trying to send a custom header for pages that start with /test-live/
The code I tried:
<If "%{REQUEST_URI} =~ m#^/test-live/#">
Header always set X-Frame-Options "...
0
votes
1
answer
71
views
Need equivalent .htaccess rule in apache just like nginx so I can get everything in URL
I have a VPS where I am using nginx and uses following to do URL rewriting.
location / {
try_files $uri $uri/ /index.php?$args;
}
Then I simply go to index.php and use the following code to get ...
0
votes
0
answers
34
views
htaccess LimitInternalRecursion error
my htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /
# Handle ...
-2
votes
2
answers
41
views
301 redirect the old domain with a certain link to a new domain with the same link
I have a problem, I want to redirect htaccess
The content of domainold.com is still used, only this URL has changed
from the Old website, namely http://domainold.com/product/register
to my new site, ...
0
votes
0
answers
44
views
Apache - How to compress (gzip) only specific calls
I have PHP application served with Apache 2.4
I need the apache to compress (mod_deflate - gzip) calls for specific users. So the application should decides dynamically which calls gets gzipped.
I was ...
0
votes
0
answers
143
views
how do i remove %20 extra keyword url error in .htaccess?
how do i remove %20 extra keyword url error in .htaccess ?
#Options +FollowSymLinks
Options -Indexes
RewriteEngine On
RewriteRule (.*)_hello_(.*)_lan_(.*)_html.html$ view_html.php?q=$1&sq=$2&...
0
votes
0
answers
68
views
Rewrite files up a directory and remove file extension
I need to rewrite files up a directory and remove the file extension
I have something like
https://example.com/dir/file.svg
and I want to rewrite the URL to
https://example.com/file
Here's my ...
0
votes
0
answers
43
views
Why does this directory rewrite only work for top-level content, not subdirectories?
I have the following lines in my .htaccess file:
RewriteCond "%{DOCUMENT_ROOT}/_legacy/%{REQUEST_URI}" -f
RewriteRule "^(.+)" "%{DOCUMENT_ROOT}/_legacy/$1" [L]
...
2
votes
1
answer
539
views
How to disable .htaccess redirect for a specific folder
I write the following .htaccess rules to redirect all URLs from www.a.com to www.b.com:
RewriteEngine on
RewriteCond %{http_host} ^www.a.com [NC,OR]
RewriteCond %{http_host} ^a.com [NC]
RewriteRule ^(....
0
votes
0
answers
35
views
How to restrict user to view directory If subDomain Url format is wrong
Currently, I am redirecting all my subdomains to a particular folder using the .htaccess file. Below I have mentioned my .htaccess file code
<IfModule mod_rewrite.c>
RewriteEngine On
# ...
0
votes
1
answer
58
views
How to block all requests starting with "?mode" on Apache?
Recently my website was hacked and now I have around 20000 indexed links in Google that were redirected to other sites via my website. Now I have stopped all redirects but I have too many request on ...
0
votes
2
answers
543
views
getting error Content Encoding Error (ERR_CONTENT_DECODING_FAILED) with Apache served pre-compressed .br (Brotli) files
How can I get Apache to serve pre-compresses Brotli files?
With Chrome I am getting
net::ERR_CONTENT_DECODING_FAILED 200
I made my pre-compressed .br (Brotli) files from minimized .html files (.min....
1
vote
1
answer
567
views
htaccess redirects with special characters on an specific url not working
I need some help creating a redirect, I'm trying to replace all - to +, but both are special characters and also want to do it only when the URL contains ?s=.
This is an example
example.com/?s=i-need-...
1
vote
1
answer
136
views
Edit .htaccess file to make file accessible
I was trying to make a WordPress plugin work, when I found, after hours of debugging, trial, errors and praying ancient Greek gods, that the plugin did not work because it was impossible for the ...
1
vote
0
answers
95
views
htaccess: I can't redirect to nested subfolders correctly on the WordPress app
I have a multilingual WordPress site that has two languages: en and tr, It's site A.
I wanna put my other WordPress site inside /tr/shop/ folder, It's site B.
Just need only these rules:
/en/anything/...
0
votes
0
answers
1k
views
configuring content-security-policy for apache virtual hosts
I have Apache 2.4 with these sites configured in the httpd-vhosts.conf file:
<VirtualHost *:80 *:8080 *:8084>
DocumentRoot "c:\apache_php\sites\public"
ServerName www.mydomain....
2
votes
3
answers
874
views
Apache 2.4.51 bypass Basic Auth for specific query string
I need Basic Auth on my website, except if a specific hash is present in the URL.
www.example.com => Authentication required
www.example.com/whatever => Authentication required
www.example.com/...
1
vote
1
answer
60
views
how to write 301 redirect by checking an special character from the url using htaccess?
I have few urls contain some special characters like below
www.abc.com/archive/category/コレクション-帯-袋帯
www.abc.com/archive/category/お役立ち情報
I want to write .htaccess to handle this redirection.
I tried ...
0
votes
0
answers
100
views
In .htaccess, can I pass on "OPTIONS *" to be handled by PHP?
I have a RewriteRule .* index.php to catch everything
Everything else seems to pass through just fine, even OPTIONS /. But Apache doesn't seem to let me handle OPTIONS *, and in fact just returns a ...
2
votes
1
answer
305
views
.htaccess return error if no RewriteRule meets the request
I'm trying my hands on writing a simple REST API and am currently trying to properly configure my .htaccess file.
What I'd like to achieve is the following:
have RewriteRules to direct requests ...
1
vote
1
answer
372
views
Apache RedirectMatch not matching double slash
I want to redirect URLs with multiple consecutive slashes (e.g. //) in the path to have only one consecutive slash, e.g.
https://example.com/a//b/c/ → https://example.com/a/b/c/.
My .htaccess file ...
0
votes
0
answers
40
views
Redirect to subdomain if specific subdirectory found in URL using htaccess
How do I redirect this (old blog domain)
https://website.com/post/182464294751/post-title
To a subdomain while keeping the rest of the url/subdir
https://tumblr.website.com/post/182464294751/post-...
-1
votes
1
answer
275
views
.htaccess makes WordPress Dashboard very very slow
Today I suddenly find the WordPress Admin dashboard is very very slow. It takes about 60s or more to access the post list, plugin list, etc. Or will just show an time-out error.
I try the following ...
0
votes
1
answer
70
views
Is it possible to set up .htaccess rule for incoming traffic from 301 redirect?
We have a permanent 301 redirect that is set up for an old site that is now being redirected to a page on a new site. Is it even possible to set up an .htaccess rule on our new sites Apache server to ...
0
votes
2
answers
482
views
How do you set the " ErrorDocument 404 / example.php " code up without running into this error?
I have been working on this "ErrorDocument 404 issue" for the afternoon and I have been unable to solve this issue just yet. Can you please help.
I have set up my custom error 404 page and ...
0
votes
0
answers
94
views
htaccess php_value works only if not nested
I have this htaccess
<IfModule mod_env.c>
SetEnvIf Request_URI ".*/my/path/to/api.php$" IS_MY_PATH
</IfModule>
<IfDefine IS_MY_PATH>
php_value max_input_vars 5000
&...
0
votes
0
answers
65
views
htaccess redirect all domains to their folders
Recently i bought another domain, and i have all of them on 1 hosting. My hosting provides me only with htaccess file where are all redirects from subdomains made. The folder structure now looks like ...
0
votes
0
answers
53
views
I want to add a custom 404 to all my URLs following a relevant pattern using .htaccess file
Hello,
Google is currently indexing query string URLs of my website. Google has currently indexed almost 112k URLs that all of are duplicate versions of other URLs causing my website to slow down and ...
1
vote
1
answer
676
views
htaccess - Generate ALLOW rule dynamically from external file
Can Htaccess set variables by external files as values?
I would like to ALLOW all IPs that are listed in a txt file located on the server.
This txt file is auto generated via script by our systems ...