Questions tagged [.htaccess]
Directory-level configuration file found mostly on Apache web servers
2,724
questions
0
votes
0
answers
23
views
.htaccess deny access to subdirectories from a certain domain
I have a server with a security flaw:
There's the main site https://example.com (on server /var/www folder)
Then there's an additional app (on server /var/www/app/public) that is configured to be on ...
-1
votes
0
answers
22
views
.htaccess 301 redirect not working wordpress
i have wordpress site with ip address, i want to setup a 301 redirect from
http://192.168.0.1/ to http://192.168.0.1:8080/, but never succeed.
.htaccess (existing)
# BEGIN WordPress
<IfModule ...
0
votes
0
answers
7
views
.htaccess allow specific extension via webdav
I have an apache server with webdav. I would like to allow only files with .zip extension to be uploaded with PUT or deleted with DELETE methods.
1
vote
1
answer
34
views
Redirect to folder only if root from other site referrer
I have a redirect from root to subfolder. If user visits https://example.com it redirects to https://example.com/subfolder. But I want it not to redirect if referrer is my site, so user can reach root ...
2
votes
2
answers
95
views
Redirect to other server and domain if file not found
I have migrated from Apache to Nginx so I want to set all rules in Nginx.
Goal: Redirect a URL to another domain with the same filename if that file is not found on the requested server.
Example
If a ...
0
votes
0
answers
12
views
Need to redirect all "mail" subdomains to main domain using mod_alias in apache include editor for server wide domain redirection
I run cPanel on my server and they have it set up so every domain.com gets a subdomain of mail.domain.com -- normally this wouldn't be a problem except the mail subdomains are exact duplicates of the ...
1
vote
2
answers
40
views
.htaccess redirect sub-folders to the correspondent index.php
How can I redirect each request for a subfolder to the index.php in the same folder
myserver.com/folder/subfolder1/test redirected to folder/subfolder1/index.php
myserver.com/folder/subfolder2/...
0
votes
1
answer
21
views
Redirect all pages to non www and one page to www
I want to redirect all my internal pages (eg: example.com/about) to their non-www version but I want my homepage (https://example.com) to redirect to its www version (https://www.example.com).
I ...
0
votes
0
answers
29
views
masking URL after redirection [duplicate]
I re-post my question in the event that I will be more clear as to what I would like to do.
I have a subdomain under a dns name, lets say it is mysub.domain . This subdomain is in a remote provider ...
0
votes
0
answers
23
views
masking after redrection using .htaccess [duplicate]
I have read many examples that use the .htaccess file method to mask a url. None of them works for me. It might be something simple that I am missing. Please bare with me.
Here is what i want to do:
I ...
0
votes
0
answers
23
views
Language directory rewrite to root Wordpress
I am trying to achieve following:
I have language directories eg.
mysite.com/en/
mysite.com/th/
and so on.
I want main site/files from root directory will be diplayed when someone enters
mysite.com/en/...
1
vote
1
answer
15
views
Setting Apache header with conditions of excluding paths/directorys / server ips
I use a WordPress plugin called Duplicator Pro and the best way of installing with their installers is to use the servers IP rather than the domain because that way it autofills & conects to the ...
0
votes
1
answer
36
views
Remove both index.php and file extension on other php pages using .htaccess
I would like to remove the need to include index.php in my links. Instead of
example.com/about/index.php
I would like it to be
example.com/about/
Secondly, I would also like other non-index pages to ...
1
vote
1
answer
22
views
On Apache how to switch off DirectorySlash only for requests to a specific subdomain?
Served by Apache I'd like on one subdomain site of mine (say sub.mydomain.com) that URLs without trailing slashes point directly (without external redirect) to the index file in the underlying folder. ...
0
votes
0
answers
28
views
Apache HTTP Header - Security and Understanding
I have now read through the handbook of Apache and tips in online forums. But unfortunately I don't understand it at all.
https://httpd.apache.org/docs/current/mod/mod_headers.html
The optional ...
1
vote
0
answers
27
views
How do I convert this .htaccess snippet to Nginx rules?
I have this snippet of .htaccess coming from Apache:
RewriteCond %{REQUEST_FILENAME} index\.php
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteCond %{DOCUMENT_ROOT}/u_pages/%1.php -f
RewriteRule .* ...
1
vote
2
answers
46
views
restrict access to a specific URL with .htaccess
Hello i am running server with xenforo. i would like to know how can i restrict url from .htaccess.
Url is : https://mywebiste.com/index.php?members/find&q=oi%5Bp%5C&_xfRequestUri=%2Findex.php%...
1
vote
0
answers
65
views
Apache: <LimitExcept POST> not working (in .htaccess)
I am trying to set some controls in Apache via the .htaccess. This works:
<LimitExcept GET>
Order allow,deny
Allow from all
Deny from all
</LimitExcept>
while this does not:
&...
1
vote
1
answer
41
views
Forbidden ... denying access to be safe [closed]
Total n00b here.
I'm running a LAMP stack using Raspbian OS on a Raspberry Pi 4 Model B.
I tried googling around, but I couldn't find a thread that matched my issue.
My jenga tower seemed pretty ...
1
vote
1
answer
48
views
htaccess rewrite only in root directory (generically)
Hi I am trying to get htaccess to rewrite only if a file, symlink, or a directory is not present with that name. Which I have successfully done with this right here:
RewriteCond %{REQUEST_FILENAME} -s ...
1
vote
1
answer
134
views
Trying to get Apache to serve webp instead of png/jpg (from /img folder of prestashop)
First post here, so I hope I did it well.
I converted all png/jpg starting from my prestashop public_html folder to webp, and added rewrite rules to the .htaccess in order to have the webp served ...
1
vote
1
answer
64
views
Apache 2.4 .htaccess Set Headers for error pages
I am setting some headers using .htaccess for a web page, f. e.:
<IfModule mod_headers.c>
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains"
</IfModule>
...
1
vote
1
answer
26
views
Add a subdomain as an exception in hotlinking
I used this code in my .htaccess file and it is working great to prevent hotlinking:
RewriteEngine On
RewriteCond %{HTTP_HOST}@@%{HTTP_REFERER} !^([^@]*)@@https?://\1/.*
RewriteRule \.(gif|jpg|jpeg|...
0
votes
0
answers
26
views
check-host.net "broken pipe" HTTP status on my Bluehost Wordpress Nginx
Issue: 502 Bad Gateway
So our team always reaches out to Bluehost Support regarding the issue. They can't fix it by themselves. We can't fix it either on the WordPress dashboard.
Please see attached ...
1
vote
1
answer
31
views
RewriteRule won't match if trailing slash present, throws nginx 404
With this .htaccess...
RewriteEngine on
RewriteRule ^foo$ foo.php
RewriteRule ^foo/$ foo.php
...I get the following behavior, when I request
/foo — works, I get foo.php
/foo/ — fails unexpectedly ...
0
votes
1
answer
115
views
Redirect HTTPS to HTTP for Safari User-Agents only
Yes, you read that right. I need HTTPS to HTTP for Safari only. Because all links referring to the site anywhere are HTTPS.
I have a website that has an SSL certificate, and normally we force ...
0
votes
1
answer
60
views
rewrite rules from apache to nginx
I have a problem with this... I'm using free hosting for giving a demo to my future buyers of my own cms.
The hosting is hubuhost.com, they are supporting the last version of php 8.1. The problem is ...
1
vote
1
answer
1k
views
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}],what does it mean?
I find new version(V5.9) of Wordpress adds this line to .htaccess:
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
Old version of Wordpress does not have this line. What does it mean? ...
1
vote
2
answers
34
views
.htaccess mod_rewrite not catching all RewriteRules
There is a PHP application with a PHP router as entry point for all the requests placed inside index.php. I am trying to write a .htaccess file to forward every request to index.php except for API ...
0
votes
1
answer
35
views
Can I make a folder on a vhost access a site held in another vhost?
I have two website codebases running on a domain as follows
www.example.com
(a WordPress site)
Exists at: /var/www/example.com/public_html
whitelabel.example.com
(a Laravel site) Exists at: /var/www/...
0
votes
1
answer
49
views
How to make only "/var/www/html/login" public on my apache2.4 server?
I need some help please.
I'm using apache2.4 on my server. I'm blocking all requests to / using the following code:
<Location />
Deny from all
AuthUserFile /path/.pass
...
0
votes
0
answers
89
views
Language based RewriteRule like mysite.com/en/ in .htaccess
I'm trying to write redirect directives in the .htaccess to forward internally all user requests like this:
Every request in a language folder should redirect to the requested file with the language ...
0
votes
1
answer
50
views
Block `//xmlrpc.php`
I'm getting tens of thousands of (quite probably malicious) hits on Apache which are bringing the server down. All hits look like this on the Apache log:
[30/Jan/2022:21:57:41 +0000] "POST //...
0
votes
1
answer
66
views
Rewriting URLs with htaccess for multiple parameters
I'm trying to rewrite this:
https://mywebsite.com/pages/article.html?id=1&title=Title-Goes-Here
into
https://mywebsite.com/pages/article/1/Title-Goes-Here
Using this Rewrite Rule
RewriteEngine ...
0
votes
2
answers
131
views
Htaccess to rewrite URL with two parameters
I want to rewrite this type of URL
https://mywebsite.com/content/page.html?id=12&title=my-page-title
to
https://mywebsite.com/12/my-page-title.html
Using generateit.net/mod-rewrite/ I got the ...
1
vote
1
answer
31
views
How to make mod_rewrite force a redirect?
I have a need to temporarily redirect my website to a static version hosted on Cloudflare. The current site is a Wordpress site hosted at Ionos and Wordpress seems to be doing a 301 redirect from ...
2
votes
1
answer
37
views
Apache incorrect url rewrite for non-existent symlink files
I have a directory (foo/uploads), which contains 1 file: file1.txt
I have created a symlink to this directory (bar/uploads)
Here is my .htaccess file inside bar:
RewriteEngine On
RewriteCond %{...
0
votes
2
answers
70
views
trying to redirect in .htaccess unless it's an admin
I am trying to write a rule in .htaccess that redirects all /wp-admin to /login UNLESS a certain user (WebAdministrator) is logging in. How do I make such a rule?
If I use:
Rewriterule ^wp-admin /...
0
votes
0
answers
25
views
I just transfered domain name and now within my .htaccess file I have two codes which seem the same should one be deleted?
RewriteEngine On
RewriteCond %{HTTP_HOST} lagiraudiere\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.lagiraudiere.com/$1 [R,L]
and this one
RewriteEngine On
RewriteCond %{...
0
votes
0
answers
38
views
How does this RewriteRule allow certain to access a file in a protected folder?
I'm trying to understand how this RewriteRule code works:
RewriteRule private/([a-zA-Z0-9]+)$ index.php?bua_v2_pf=$1 [L]
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule content/images/protected(\/[A-Za-...
1
vote
1
answer
66
views
Rewriting to point to a CDN
I'm hoping to use a CDN to deliver all our image files. We call the images by simply using the CDN's domain instead of our own. I could easily change the domain reference in our content management ...
0
votes
0
answers
10
views
Permanent redirect URL in uppercase to lowercase using htaccess [duplicate]
I have the URLs in large letters and I need a permanent redirect to small letters.
http://localhost/test/en/Ads-1-Alsace-Bas-Rhin-Cars-Demo01-Particular
Redirect to:
http://localhost/test/en/ads-1-...
0
votes
0
answers
137
views
Convert .htaccess rules to nginx format
I bought a ready-made Laravel script that was developed to run on Apache server, and the developer doesn't support to Nginx rewrite rules. Can someone help me? When I try to access the system on my ...
1
vote
2
answers
45
views
How to use Mod Rewrite to access non-document-root folder files?
I have the following structure for my website codes at /var/www/html
-- files
---- test.txt
-- app
---- SomePhpCodes.php
---- SomePhpCodes.php
-- public
---- index.php
---- .htaccess
The document ...
1
vote
1
answer
30
views
Apache .htaccess causing images to load extremely slowly
I am running a single page application that requires the following lines on my .htaccess . However, images on its /images/ folder are now loading extremely slowly.
Is there anything wrong with the ...
1
vote
1
answer
60
views
htaccess rewrite rule not working with file extentions
I have two domains setup on the same folder on a server.
i.e.
dl.d123.com @ /var/www/public_html/dl.domain123.com
dl.domain123.com @ /var/www/public_html/dl.domain123.com
I have an htaccess file ...
0
votes
0
answers
14
views
How to host a page under an external subdomain? [duplicate]
Expected:
A visit to news.autobahncph.dk loads content from leadautomation.dk
The url should not change once the content is loaded
Example:
Let's say that a user visits: news.autobahncph.dk/page-...
2
votes
1
answer
109
views
Why the redirection in .htaccess not work?
I have a Wordpress website. I want to redirect .php urls to the ones without the .php suffix. The .htaccess is as follows:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
...
0
votes
0
answers
384
views
Deploying symfony 5 application to shared hosting with just FTP access
I'm trying to deploy a Symfony web application on a server that only gives ftp access, without ssh possibilities, and I could only put files on two root folders: /data and /html folder. I'm trying to ...
0
votes
1
answer
46
views
301 redirect for some pages and all other pages
I have two websites. Let's say siteA.com and siteB.com.
Now I want to add 301 redirect to siteB.com.
Some of pages of siteB.com need to be redirected to some specific pages on siteA.com
All other ...