Questions tagged [.htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
2 votes
1 answer
830 views

used colons for url htaccess http://localhost/1:1

I have a problem with the colons used in url this my url http://localhost/1:1 this my htaccess RewriteEngine On RewriteRule ^/(.*):(.*) index.php/$1:$2 this error show Forbidden You don't have ...
1 vote
1 answer
550 views

Allow files to be listed when viewing a directory but protected (via HTTP authentication) when accessed directly

I created a password protected directory using .htaccess and .htpasswd, but the files don't show up when I go to the directory URL. I have this in my .htaccess: #Protect multiple files <FilesMatch &...
2 votes
1 answer
1k views

Apache with HTTP/2 and per-directory upload_max_filesize

I just upgraded my apache2 server on Debian 9.13 Stretch to start using HTTP/2. As far as I'm concerned, that requires switching from mod_php to PHP-FPM. The problem is that PHP-FPM does not obey ...
2 votes
2 answers
176 views

.htaccess & .htpasswd

I have this project where I have a front and back. My login file is simple if the login and password are in my database then I'm directed to a page in the back, otherwise I can't go. I login into the ...
3 votes
1 answer
2k views

Why is my .htaccess and .htpasswd not working?

I have .htaccess and .htpasswd files in the directory that has png files that I want to protect. .htaccess AuthType Basic AuthName "Co to za nielegalne grzebanie w plikach, juz dzwonie na ...
0 votes
0 answers
2k views

How to whitelist ipv6 in .htaccess to allow website access

I've got an online web tool and I want to give access to a company. At the moment, access is controlled by IP via the .htaccess file. The company I want to give access to are on an ipv6 address and ...
1 vote
1 answer
463 views

After installing script all subdomains go to the main domain

I have a main domain www.example.com. and the following subdomains under the main domain support.example.com test.example.com Previously both subdomains are working fine. But after installing a PHP ...
1 vote
1 answer
470 views

Replace AuthUserFile with the password itself or reference a relative path to the folder

I have a PHP script that generates 100s of directories and in these directories contain CSV files. I'm able to protect these CSV files using AuthUserFile if it points to an absolute .htpasswd file, ...
2 votes
1 answer
579 views

When changed to WWW, all URLs showing index.php?page= how to remove index.php?page=?

I recently managed to direct all URLs from non-www to www as I had an SEO error regarding duplicate websites. Once I have applied www rules then all my URLs start showing index.php?page= which doesn't ...
3 votes
2 answers
17k views

One RewriteCond for multiple RewriteRules

I need to preserve all user query strings. RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^$ index.html?page=home&%1 RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^about$ index.html?page=about&...
1 vote
1 answer
83 views

2 websites hosted on same domain, 1 needs to look like a subfolder ( /blog)

I bought a VPS for my new project running apache. On it I have 2 websites on the same domain. The first one is Ruby on Rails /var/www/html The second one is Wordpress /var/www/blog I want Wordpress to ...
0 votes
0 answers
87 views

Regex on htaccess file gives INTERNAL REDIRECT error

I'm trying to create a redirect rule that matches the following urls: en/property/rotterdam/apartment/lorem-ipsum-dolor-sit-amet/v-9/ en/property/rotterdam/apartment/lorem-ipsum-dolor-sit-amet/9/ en/...
1 vote
1 answer
691 views

.htaccess redirect empty directories to index.php but it's showing function name instead of executing it

Hi I have a LEMP Server and I have used .htaccess file as bellow to redirect empty directories to index.php but the problem is that it's not executing the code in the index.php it's just printing the ...
0 votes
2 answers
81 views

What is the reason for this falsely redirect to www.www2.example.de

I set up a testserver for our main website www.example.com. I set the apache-sites-config to www2.example.com. I deleted the .htaccess / adjusted it to hold the basic wordpress-entries. I disabled the ...
6 votes
1 answer
54k views

URL rewrite with multiple parameters using .htaccess

I have four different types of rewrites I'm trying to do with multiple parameters in each. First, the URLs with no modification: http://www.example.com/index.php?p=/category/page-slug&pn=2/ http://...
0 votes
0 answers
331 views

Exclusion in Rewrite Rule

I have a rule in .htaccess redirecting all HTTP requests to HTTPS. I need to exclude two specific paths because they are called by a legacy application to download a file, connecting using TLS 1.0 (...
1 vote
1 answer
2k views

Issues with Require IP on Apache 2.4 and Ubuntu 20.04 server

I have setup a subdomain (staging.callkneehill.ca) on my server and have created a .htaccess file with the following parameters: <RequireAny> Require ip 70.65.194.109 </RequireAny> ...
0 votes
1 answer
57 views

How to redirect search.php?query=test&search=1&s=1 to /query/test

I have tried other things, but I cannnot get it to work, when I go to the main website, (index.php is just a include of search.php) it will send me to this /query/search.php/search.php/search.php/...
0 votes
2 answers
4k views

Apache .htaccess set a header if Request URI does not exactly match a desired value

Goal: using a .htaccess file in /directory/, if request URI does NOT exactly match "/directory/" then set a header. For example, the header SHOULD be set if the request URI is "/...
2 votes
2 answers
2k views

Using several rewrite rules .htaccess

I have a website wich is based on a searchpage, which shows a list, and next is a detail page of the items. if visitors use rootdomain.com/searchterm, should be redirected to rootdomain.com/index....
4 votes
2 answers
609 views

How to use [OR] or substitute in an .htaccess file?

Summary The [OR] flag isn't working consistently across different servers. Details and question below. I have a website hosted on Godaddy and I wrote this code for an .htaccess file to redirect ...
2 votes
1 answer
844 views

How to get line number of error that .htaccess apache2 is reporting in /var/logs/error.log

I get a internal server error after adding redirects to .htaccess - I've added 600 of them. I check /var/logs/error.log [Wed May 12 16:26:02.600394 2021] [core:alert] [pid 8071] [client 127.127.127....
1 vote
1 answer
7k views

Permanently Redirect Subfolder Blog to Subdomain on Another Server

Seems this server redirect question may be better suited for serverfault than wordpress stack exchange. Originally we had a static marketing site at example.com and the wordpress blog hosted at www....
1 vote
1 answer
47 views

PHP processing pages for forms not following line with rest of files

I'm a web developer hobbyist. I'm over 50, never had a true web dev job but like to tinker in my spare time for fun. That said, I have a web site hosted by Bluehost that I wrote with PHP from scratch. ...
2 votes
1 answer
302 views

.htaccess not working - on add on domain

The original domain files are under /home/account/public_html, the add-on domain is /home/account/add-on-domain. Both sites have a .htaccess file, all the same, apart from the domain names, both are ...
1 vote
2 answers
4k views

how to remove .php extension using htaccess on godaddy linux hosting

How to remove .php extension using .htaccess file. I have tried many examples without success. An Internal server error is regularly showing. I am using Godaddy Linux Hosting. This code is the latest ...
0 votes
1 answer
762 views

Apache 410 a URL Without Affecting Sub Paths

I'm trying to kill a URL, so in my .htaccess file, I put: Redirect 410 /my-path It works. If I try to visit: https://www.example.com/my-path I get: Gone The requested resource is no longer ...
0 votes
1 answer
506 views

.htaccess redirect from SSL root domain to another subdomain with different SSL causes NET::ERR_CERT_COMMON_NAME_INVALID

I need help to figure this out. I have two local, separate webservers 192.168.11.5 (https://www.example.com) and 192.168.9.14 (https://project.example.com). Each has separate non-wildcard SSL ...
2 votes
1 answer
1k views

How do I exclude my sitemap from httacess redirect?

I want all urls to be redirected, except my sitemap xml file in the root directory. The htaccess should allow https://old-domain/xml.xml to resolve with HTTP 200, but it is still redirecting to the ...
2 votes
1 answer
8k views

Force SSL for every URL except one path using .htaccess

I'm trying to enforce SSL for every URL except one with the first segment /preview. http://test.example.com/preview/blah/blah should be ignored by the rule; every other URL should be forced to use ...
1 vote
1 answer
2k views

Nginx htpasswd getting 403 after successful login

I want to access the folder /folder/subfolder/ in the webservers root (/var/www/dl.somewebsite.com/files/) with a password the rest should be public accessible. Using the script below I get a 403 ...
1 vote
1 answer
150 views

Redirect the document root and a specific page only to another domain

Might sound confusing, but what I want to achieve is this: If the user visits: www.mydomain.com (with or without www.) transfer them to: www.myotherdomain.com/welcome-old-users At the same time, I ...
15 votes
6 answers
2k views

to www or not to www [duplicate]

Possible Duplicate: What’s the point in having "www" in a URL? Should I use www in front of a URL or not? Some sites say we should and some say the opposite. Pros Cons If there is no www ...
1 vote
1 answer
3k views

Apache Do Action Only If Path Contains

I'm using the following in an .htaccess to remove the extension from .php files: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] It works great, but how can ...
1 vote
1 answer
805 views

.htaccess redirect based on the visitors host name, not IP address

I have done several attempts to figure out how to redirect visitors from the visitors hostname to some other place. I know with IP this works: RewriteCond %{REMOTE_ADDR} ^185\.93\.180\.* [OR] ...
0 votes
0 answers
165 views

multiple htaccess redirects to a new domain

I'm trying to redirect an entire domain over to another domain while also redirecting a couple of specific pages to specific locations. I also want to preserve www and https on the original domain to ...
1 vote
1 answer
3k views

Apache rewrite causes server error 403 when genuine directory exists after extension removal rewrite

I've spent a couple of days now trying to create a specific rule set that will allow me to remove .html extensions from all the files in the directory and present neater URIs. I'm using a .htaccess ...
1 vote
1 answer
1k views

Apache .htaccess - If directive to evaluate if home is the current page

I'm just trying to set a header if the loaded page is home (/), however, I can't manage to do that. What I've tried: #let's find var value - its echo / on the header PassEnv REQUEST_URI Header always ...
0 votes
1 answer
160 views

Apache Redirect with OR Operator

How can I use the Apache OR operator to redirect several paths to one URL? E.g.: RewriteEngine on RedirectMatch 301 /foo || /foo/bar || /das.html https://example.com/ext/ddy/$1 Thanks for any help.
0 votes
1 answer
12k views

Preserve HTTP referer when using a 301 redirect

I have htaccess detecting absent folders with the action of then sending the user to another page with a 301 re-redirect. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...
1 vote
1 answer
485 views

.htaccess Redirect 301 - Single pages work fine, homepage doesn't

I'm trying to redirect some specific pages to the new ones on my new site (these redirects work fine) and, finally, my homepage OR (even better) my homepage and all the pages which I didn't redirect ...
0 votes
0 answers
38 views

apache (httpd) - How to set rewrite URL [duplicate]

I have a new website on Nette Framework, the problem is that the old website had URLs in the form: https://example.com/Questions/ https://example.com/Tags So all over the internet there are backlinks ...
0 votes
0 answers
192 views

My .htaccess causes 'redirect error' in Google Search Console, or a bug?

I'm having an issue with Google Search Console. It seems it can't redirect my pages properly, so in Coverage it returns some 'redirect errors' when it shouldn't. Let's say the link: https://example....
1 vote
0 answers
20 views

Public WordPress Website unaccessible from inside active directory with same domain name, but simple html file is accessible

a client uses the same corporate domain for his internal network / office365 installation as for the public website. The website and domain are hosted on a shared host, the site is serviced by me. ...
2 votes
5 answers
3k views

500 Internal Server Error when adding a line in the .htaccess file

I need to add the following line into my .htaccess file in order to get my website working with mod_security SecFilterScanPOST Off but then I get an error Internal Server Error The server ...
4 votes
1 answer
12k views

AddType application/x-httpd-php .html stopped working

I have the following line in .htaccess AddType application/x-httpd-php .html .htm And it used to work for years to treat html pages as php, however recently I noticed it is not working anymore, ...
1 vote
1 answer
209 views

Difficulty accessing folders .htaccess

I need to migrate a site running on Prestashop 1.6.1.10 to the latest version. I have a problem: I uploaded the new version to a new folder called shop, but I can't access it due to .htaccess. Here is ...
5 votes
2 answers
20k views

htaccess order Deny,Allow rule

I'd like to dynamically add IPs to a block list via htaccess. I was hoping someone could tell me if the following will work in my case (I'm unsure how to test via localhost). My .htaccess file will ...
5 votes
2 answers
5k views

How to add/ignore a subfolder in htaccess file?

I have build an app at http://url/sdf19/ I have a .htaccess placed in /sdf19/ containing RewriteRule for clean urls. But I have built a PDF generating tool, which is in a subfolder /inc/tools. I ...
1 vote
1 answer
914 views

.htaccess in Apache2 for php urls

I am trying to map any URL such as localhost/first to localhost/first.php using mod_rewrite for Apache on Ubuntu 15.04. Here are the steps. Installed Apache2, PHP5 using (apt-get apache2, php5) ...

1
5 6
7
8 9
57