Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Directory-level configuration file found mostly on Apache web servers

2
votes
2answers
30 views

How to show 410 Gone status for subdomains that are already been deleted

I bought an auctioned domain to build my new project, from my analysis with Ahrefs, people that were behind this domain had a subdomain called "forum" for their forum, and somehow they didn't know how ...
1
vote
1answer
48 views

RewriteEngine .htaccess rules end up redirecting to example.net/https:/example.net

I'm starting to learn about the Apache .htaccess and I have some issues in my website... RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{...
3
votes
1answer
44 views

How to redirect a specific search result using .htaccess

When searching for "interesting people" the search results page of my website is https://example.com/?s=interesting+people&submit.x=0&submit.y=0 Instead of displaying that search results page ...
2
votes
2answers
44 views

Installing WordPress with /wp path leads to redirect loop when index.html redirects to a shopping cart

So on my site, my shopping cart is located at example.com/zc2 I use this .htaccess file RewriteEngine On Redirect /index.html example.com/zc2/ So that anyone that lands on example.com will be ...
2
votes
1answer
30 views

Htaccess redirect pages from subfolder to root directory while preserving any query string

I have moved pages in various sub directories to the root directory and want to set up a 301 redirect for each page and keep any query string that might be present. For example: www.example.com/...
-1
votes
1answer
74 views

How to remove trailing slash from my root URL in htaccess?

I've tried several ways to remove the trailing slash from my URL in .htaccess and nothing worked but now even my URL can't be found because now it has a slash. Here is what my .htaccess looks like. I ...
2
votes
2answers
38 views

Can .htaccess be used to set file permissions?

Is it possible to define file type permissions through .htaccess? I have a site that uses .pl and .cgi scripts which require 0755 CHMOD. The shared server setting is apparently geared for WordPress ...
0
votes
0answers
39 views

Use htaccess to check if cookie value exists in requested url

Im stuck if my idea of getting .htaccess to read the cookie value and check if this value is within the requested url. This is my idea: RewriteBase / RewriteCond %{HTTP_COOKIE} custom_cookie=(.*)$ ...
4
votes
1answer
63 views

Moved images to another folder - need help with htaccess rewrite rule for png

I had to move my image folder. Before it was example.com/shoplogo/(name*).png now its example.com/shop-logo/(name*).png just stuck with the rewrite rule :-(.
1
vote
1answer
20 views

Change max_input_time when you don't have access to php.ini file

I am using freehosting website to host my wordpress blog. However, while trying to use duplicator plugin to migrate my blog it asks me to change the max_input_time value to 0 I don't see php.ini file ...
0
votes
0answers
72 views

.htaccess rules to remove .php and add a trailing slash are not working

I am trying to go from example.com/filename to example.com/filename/ I have tried almost all possible solutions for getting a trailing slash in my URL but somehow it seems to conflict with the rest ...
0
votes
1answer
51 views

How to migrate from HTTP and HTTPS old sub domain to HTTPS root new domain in htaccess with least SEO risks?

Looking for the best site migration strategy for SEO, which consider these specific combinations of elements and challenges: *note: site is in Wordpress. Htaccess redirect code to go from sub ...
2
votes
1answer
38 views

Block blank user-agents bots but make exception for ip address possible?

I have the following in my .htaccess file on website2, but when my other website on website1 makes requests to website2 it is blocked because the server user-agent is blank. Is there are a way to ...
5
votes
2answers
41 views

In .htaccess files, is there any difference at all between “!=on” and “off”

I’m trying to better understand Apache’s use of a binary attribute. In an .htaccess file with the code # Check if HTTPS is 𝗻𝗼𝘁 𝗼𝗻 RewriteCond %{HTTPS} !=on Is there more processing occurring&#...
2
votes
0answers
38 views

Local browser caching not working due to .htaccess rules

All the JavaScript files hosted from my server are not being cached - just those from 3rd party CDNs. The information on caching is bountiful, but I've been unable to create something that works. I'...
2
votes
2answers
64 views

Wordpress htaccess redirect from http to https

Currently I use this rule on my WordPress .htaccess file to redirect HTTP to HTTPS: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{...
2
votes
0answers
16 views

htaccess requesting password twice

I am using .htaccess to password-protect a directory. When users attempt to log in, they enter a username and password, and are refused access --- but if they try a second time, they get in just fine ...
2
votes
1answer
25 views

.htaccess to redirect domain1 to domain2

I currently have a .htaccess file with the current lines to force HTTPS: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] My main domain is ...
1
vote
0answers
42 views

Combining password protection and redirects in .htaccess file

I'm a designer who developed a simple site with HTML and CSS. I'm completely new to .htaccess so it's not surprising I'm struggling to get the file to work as I want. Problem 1: I want to password ...
4
votes
1answer
45 views

How can I redirect all PDF files with file names that don't start with “public” to the home page?

I would like to disable direct access to all PDF files except those with a public- prefix on the beginning on the file name (e.g., public-samplepdf.pdf) so they can be viewed in public. I'd like to ...
3
votes
2answers
49 views

How to use X-Robots-Tag to noindex all subdomains (save specific exceptions)?

Google's Robots meta tag and X-Robots-Tag HTTP header specifications page (Practical implementation of X-Robots-Tag with Apache section) gives an example of noindexing certain filetypes, ie: <...
4
votes
1answer
43 views

Whats the correct htaccess line to direct from sub-domain to main domain

We have a blog on a subdomain which needs to be moved to the main domain ie: blog.example.com/post-title to example.com/blog/post-title Do I need to create a redirect match for each individual post/...
0
votes
1answer
45 views

.htaccess Redirect if no sub string found in the URL

Whenever user comes in example.com how to redirect them to example.com/home Note: The current routing/URL paths should work after adding this condition/rule For example: example.com/about-us -> no ...
0
votes
1answer
24 views

.htaccess rewrite rules working on Mac Apache 2.2 but not on CentOS Apache 2.4

I've run into an issue when moving from a test server to a production server. I have a set of .htaccess rules in a file in the public_html site root: #Root directory htaccess RewriteEngine On # ...
0
votes
1answer
25 views

what is url robot search engine when enter to my website [closed]

what is url search engine robots when enter to my website for example i add this code in .htaccess this code just allow google robots read the robots.txt i need to add url ( msn , yahoo , bing ) ...
1
vote
1answer
52 views

Overwriting cookies in htaccess

I run a website in a quite cheap shared hosting environment (LAMP): technically speaking, in this context the only thing I can do is edit one or more htaccess files. Maybe for load balancing purposes,...
2
votes
1answer
26 views

How to have .htaccess display 404.html for child pages

I am working on a website example.com that has an error page example.com/404.html. Here's my entire .htaccess file (Apache): # Forces HTTPS RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(....
-1
votes
1answer
36 views

I cannot do https redirection on my website on .htaccess

Am having a local classified website. I bought SSL for the domain but cannot put https redirect on htaccess since my developer wrote somerule on htaccess to get url for SEO. Can some help for the same....
3
votes
2answers
94 views

.htaccess using HTTP_HOST has one extra extraneous redirect when forcing HTTPS

When I use these lines in my .htaccess file, everything works well: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://example.com%{REQUEST_URI} [L,R=301] Then I tried to make it ...
2
votes
1answer
310 views

Redirect URL without lang directory to default language

This: example.com/test/ should redirect to: example.com/en/test/, but: example.com/es/test/ shoudn't redirect. in this case /test/ could be anything, with any number of levels (i.e.: /test/succeeded/ ...
1
vote
1answer
155 views

.htaccess redirect dynamic URL (with numeric ID) to remove “track” from the end

It seems to be easy, but I can't figure out how to solve it, nothing worked for me. I have a dynamic URL like: http://www.example.com/user/46/track and I want to redirect from that URL to http://www....
1
vote
0answers
14 views

Disallow URLs made with mod_rewrite in robots.txts [closed]

Here is my robots.txt file: User-agent: * Disallow: /head.php Disallow: /head/ Disallow: /head Disallow: /header.php Disallow: /header/ Disallow: /header Disallow: /footer.php Disallow: /footer/ ...
1
vote
2answers
125 views

WordPress multisite ERR_TOO_MANY_REDIRECTS where the domain name ends up in the path for nonexistent pages

I have a WordPress multisite setup with subdomains. I have pointed five subdomains to it. I have also installed SSL to main domain and the other subdomains. I have written the below Redirect code for ...
1
vote
1answer
88 views

RewriteCond %{HTTPS} !=on is not working even though RewriteCond %{SERVER_PORT} !^443$ works

I have a requirement to check for non HTTPS URLs in htaccess. My understanding is that RewriteCond %{HTTPS} !=on will match all URLs that are not HTTPS. But upon testing, I find RewriteCond %{HTTPS} !...
3
votes
1answer
34 views

Problem with .htaccess for files having similar kind of names

I have a file with name lang.php and another file in the same folder with same lang_inst.php. The .htaccess am using is: RewriteEngine On Options -Indexes RewriteCond %{REQUEST_FILENAME} !-d ...
1
vote
0answers
141 views

Cannot figure out how my nodejs application run with apache

I need to push my node app updates to remote host which is really wired. It uses standard cPanel + apache bundle, but also has node installed. Root domain mywired.host hosts static files from ...
2
votes
1answer
38 views

Are these 3 redirect rules equal?

I would like to redirect the non-https and non-www versions my domain to the https and www version of it. I'm a bit confused by the options. Are these redirect rules equal for my purpose? # REDIRECT ...
1
vote
0answers
25 views

.httaccess password protection not working on recently updated browsers

My situation is this: I have a web folder on an Apache server protected with standard .httaccess password protection. It's been working fine for years and the code hasn't been modified in any way. In ...
2
votes
2answers
178 views

How is it best to redirect http to https in cPanel?

I am setting up a new site on a domain that has an SSL certificate. The DNS is all configured correctly and I can access the site on either http://example.com or https://example.com URLs. Currently, ...
4
votes
2answers
283 views

How to force ssl and www for a subdomain as an independent domain?

I have own the example.tld . I want to force SSL and https for root-domain and all of its subdomains. I have used below code in .htaccess file of root-domain: RewriteEngine On RewriteCond %{HTTPS} ...
3
votes
1answer
372 views

How to Redirect Pages with Query String?

I want to Redirect as seen below: https://example.com/p1/p2?sort=p.model&order=ASC&page=2 to https://example.com/p3/p4?sort=p.model&order=ASC&page=2 Also, I have this code in my ....
4
votes
2answers
255 views

Rewrite all URLs within subdirectory to index.html so JavaScript can use the path

I have a part of domain example.com/~mypart. In that folder is index.html. If I visit example.com/~mypart/something I get a "Not Found" error. I want every address with some string after example.com/...
0
votes
1answer
174 views

Remove two subfolders and change plusses to dashes in the URL using .htaccess

I'm in the process of migrating a website from an old CMS to Wordpress. The way that some of the old URLs were: http://www.example.com/tags/tagged/tag/tag+name For Wordpress, I need it to be the ...
6
votes
3answers
612 views

Is an .htaccess edit necessary when enabling Cloudflare SSL?

I have recently changed 3-4 of my sites to Cloudflare SSL. After that, I went to General Settings on WordPress and changed URLs from HTTP to HTTPS. And it redirects from HTTP to HTTPS without any ...
1
vote
0answers
66 views

How do I serve webp images from my WordPress site but exclude the WP backend/admin

For some reason that I cannot fathom, my Chrome installation does not show me webp images from my website. I can see webp images on other sites (I think - how can you tell if you are being served a ...
4
votes
1answer
183 views

Can a URL with a # anchor be redirected in .htaccess?

I believe this can't be done, but it would be good to confirm either way. To know if it's worth investing more time in or not. Can a .htaccess file rewrite/redirect: example.net/postname#heading2 ...
1
vote
0answers
40 views

How best to handle a common mis-spelling of my domain name?

My surname is Kirkby, but very often people mis-spell it, by leaving out the second 'k' and so spell it as Kirby. My domain name is kirkbymicrowave.co.uk, but I took a guess that a few people at ...
2
votes
1answer
34 views

Redirecting from one page to another page on my website causes 404 error after using .htaccess file

Currently I'm working on a PHP blog. Where I have used an .htaccess file to get a clean URL, here is the code: RewriteEngine On RewriteCond %{HTTPS} !=off RewriteCond %{HTTP_HOST} ^example\.com$ ...
2
votes
1answer
209 views

How to redirect all pages of site A, including those with query strings, to homepage of site B

I want to redirect all pages of SiteA to homepage of SiteB. I used this code in SiteA's .htaccess file: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^(.*)$ https://SiteB.tld/ [...
1
vote
0answers
31 views

.htaccess redirect to new domain with new page name [closed]

Does anyone know how (or if) I can do an .htaccess redirect if both the domain and page name have changed? I can get olddomain.com/page/ to redirect to newdomain.com/page/ (same page name), but not ...