Questions tagged [.htaccess]
Directory-level configuration file found mostly on Apache web servers
2,829
questions
17
votes
1
answer
56k
views
Apache .htaccess <ifModule not allowed here
Running Apache on Ubuntu Precise, with PHP 5.5
Trying to access my var/www/ gives me a 500.
/var/log/apache2/error.log
shows:
/var/www/web/.htaccess: <IfModule> not allowed here
my .htaccess ...
13
votes
3
answers
8k
views
How can I redirect an entire site to a single page?
I'm in the process of shutting down a site, and have replaced the old site with a single "nobody home" page at the root level of the site. Now I need to set up some redirection, so that any ...
0
votes
1
answer
533
views
Blocking Port 8080 from direct IP access but allow access via domain (Virtualhost Config)
I want to access web server from http://subdomain2.domain.com from URL but not from direct IP (http://1.1.1.1:8080). For instance, below is my virtualhost config file (site2.conf) in /etc/apache2/...
1
vote
1
answer
1k
views
Using an htaccess file for 410 (gone page) prevents use of images
I am shutting down a website. I have deleted the wordpress site and the only page left in the domain is a page announcing the permanent shutdown of the site. The URL of the shutdown page is...
http://...
2
votes
3
answers
16k
views
Redirect Multiple Domains to Subfolders and Hide the subfolder from URL
I have sat up two virtual host on the same ip and same document root with Apache, because I want to use shared files and contents in the document root.
I want my second website point to a subfolder ...
1
vote
2
answers
2k
views
Redirecting into my Laravel project folder
I have the following content in my .htaccess file. I expected it to redirect to my project folder /hc which is at the same level as .htaccess. The redirection is not happening and it is still ...
0
votes
0
answers
951
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
vote
1
answer
566
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 ...
3
votes
2
answers
5k
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 ...
2
votes
2
answers
7k
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
841
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 ...
1
vote
1
answer
194
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 ...
0
votes
1
answer
2k
views
Use .htaccess rewrite rules on Microsoft IIS
In the last few days there's been reports [1][2] of an attack targeting WordPress sites. In this blog post it is described how to mitigate automatic login attempts using .htaccess with the following ...
0
votes
0
answers
105
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
145
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 ...
1
vote
2
answers
34k
views
How to disable the automatic redirection in WordPress-htaccess-file
WordPress has a function in its htaccess-file which performs an automatic redirection if the filenames match with an existing source.
For example if you type in http://rechnen-in-der-wolke.net/...
0
votes
1
answer
3k
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
259
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. ...
5
votes
2
answers
2k
views
RewriteRule "P" flag results in server 500 error
I am using RewriteRule in my .htaccess file to modify an incoming URL. It works fine except I want the rule to act as a proxy, rather than a redirect. But if I append the [P] proxy flag to the rule ...
1
vote
0
answers
115
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
2k
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
1
answer
1k
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 ...
2
votes
1
answer
12k
views
.htaccess rewriterule if/else
I have the following .htaccess code:
RewriteEngine on
<if "%{HTTP_HOST} =~ /^helpdesk\./">
RewriteRule ^/?$ /index.php?pages=helpdesk&file=index [NC,L,QSA]
</if>
<if "%{...
1
vote
1
answer
2k
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
7k
views
htaccess redirect from subdomain directory to main domain
I need redirect all requests from subdomain specific directory to main domain
Example:
dev.example.com/directory/test
need to redirect to
example.com/directory/test
(redirect only requests with ...
1
vote
1
answer
345
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
70
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/...
1
vote
1
answer
1k
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
99
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
1
answer
2k
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 ...
1
vote
1
answer
3k
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
2
answers
924
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
442
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
...
2
votes
3
answers
6k
views
Apache - 403 forbidden to access some static files
I'm having a hard time with .htaccess directive. I'm trying to have URL rewriting for Codeigniter framework.
Everything works as expected on the production server but I'm not able to properly set up ...
0
votes
0
answers
164
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 ...
1
vote
2
answers
1k
views
How to use Env in mod_substitute?
Okay, I'm not very strong at htaccess. I have a code:
SetEnvIf GEOIP_COUNTRY_CODE US LinkC example1
AddOutputFilterByType SUBSTITUTE text/html
Substitute s/example2/env=LinkC/ni
I'm trying to ...
0
votes
1
answer
1k
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 //...
1
vote
2
answers
847
views
After removing .htaccess can no longer access phpmyadmin
Raspbian running on raspberrypi 3+ apache 2.4
I was trying to secure my server a little better and I enabled .htaccess by changing apache2.conf line AllowOverride None to AllowOverride All and added a ...
2
votes
2
answers
7k
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 ...
0
votes
1
answer
996
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 ...
3
votes
2
answers
5k
views
.htaccess hide “last modified” and “parent directory”
I'm trying to get my .htaccess file to list all files in the current directory, hide the 'last modified' column and also remove the link to "Parent Directory" all in the 'fancy' style.
My current ...
1
vote
1
answer
638
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 ...
4
votes
3
answers
2k
views
.htaccess redirect umlaut domain
I am trying to redirect requests from a umlaut domain to another domain.
My following code works with ANY other domain, but not umlaut:
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} !=on
...
0
votes
1
answer
1k
views
mod_expires does not affect caching
I have mod_expires installed in Apache on CentOS VPS. It is also listed in the loaded modules, I checked by this command /usr/local/apache/bin/httpd -l
When I place the code in .htaccess, and then ...
2
votes
1
answer
187
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
396
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
31
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
302
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-...