Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
0
votes
0answers
12 views

website transfer from folder in public_html to root domain [closed]

I just transferred my website from example.com/newsite to example.com by moving the folder where everything was stored (newsite) into my public_html to make it the root domain. Now I am receiving ...
1
vote
1answer
30 views

Removing Some Content from website by giving 410 status code

I have some content to be permanently deleted from my website. This is a permanent deletion and I am planning to give 410 status code. I can very well return the status code in PHP page as header( "...
0
votes
0answers
30 views

Redirect 301 issue with URLs containing question marks [duplicate]

I'm trying to do some basic point to point redirects using 301 redirect 301 with a .htaccess. All is going well but there is one type of URL that is not happy. I'm trying to go from: http://www....
2
votes
1answer
49 views

How to stop cPanel messing with .htaccess and causing unexpected redirect

So I have many domains on one cPanel account, say filmstore.net, bookstore.com and sandwiches.org (the main domain). So I want to redirect anything.sandwiches.org to sandwiches.org, so I have the ...
0
votes
0answers
14 views

How can I get rid of these outbound links slowing my YSlow score? [duplicate]

I'm trying to make my website faster and GTMetrix tells me that (among other things) these links are lowering my YSlow score due to Leverage Browser Caching not being enough. They're all third party ...
1
vote
0answers
123 views

Use .htaccess/SSH/Cpanel to prevent a specific part of a specific PHP script from being processed

I have a website built with MediaWiki CMS which I host on a CentOS based Apache "shared server environment" (SiteGround) in which I can partially control Apache by: .htaccess files SSH Some Cpanel ...
1
vote
0answers
27 views

What does this code do? [closed]

I've been looking at ways to make websites more secure and in particular WordPress site and found a blog post with a few suggestions. Most of them I was already using but found this one with no ...
2
votes
1answer
51 views

How To Create An Exception, or or exclude certain files from a php-file-extension Snippet in .htaccess? this example failed

This is a .php file extension removal snippet, for displaying links online. RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC] RewriteRule ^ %1 [R,L] This is where I make an exception to ...
1
vote
1answer
52 views

Serve all pages over https not just homepage

I want to serve all of my website pages over https, but currently my htaccess only serves the homepage over https. This is the code I have in my htaccess file: <IfModule mod_rewrite.c> ...
1
vote
3answers
4k views

301 redirect from “/index.html” to root if index.html not exist

Can I create 301 redirect from "index.html" to root directory if file "index.html" not exist? For example: link "http://example.com/index.html" show "404 Error" page. I need 301 redirect to root ...
3
votes
1answer
32 views

Non-existent subdirectories of index.php do not return “404 not found”

My website usually correctly returns 404 not found errors if I enter names of documents or folders that do not exist. However, I have recently noticed something strange. The homepage of my website is ...
1
vote
1answer
27 views

How to deindex an URL with specific parameter?

While I was doing an audit of my website SEO, I found a warning for a page that is most of the time blank. Basically, this page serves for storing articles for visitors who would like to read their ...
2
votes
1answer
30 views

.htaccess - RewriteRule for 404 and query

I am very new to this stuff. I have a website with these RewriteCond/RewriteRule directives. Options All -Indexes RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}...
2
votes
2answers
140 views

How can I create a dual URL system?

I'm looking for a simple trick Let's say I have a Wordpress installation and image resources in this URL http://example.com/wp-content/images/example.jpg I would like to have the possibility of ...
1
vote
0answers
53 views

Someone is 301 redirecting penalized websites to my website

Some is doing a negative seo attack on my site 301 redirecting toxic sites to my site, I have done research and noone online seems to have an answer, would disavowing the domain doing the 301 work or ...
3
votes
1answer
133 views

Configuring .htaccess to block every request what not image in specified folder and subfolders

I have upload folder where registered user can upload files. How to block all http requests except .png .jpg .gif to upload folder and all sub-folders? Other than upload should not be affected. It ...
2
votes
1answer
27 views

How do I create clean URLs such that what is currently in a parameter goes in the path?

My url is http://localhost/store/product-detail.php?p=prod%name%test i want it to look like this http://localhost/store/prod-name-test or something like this as other stores do http://localhost/store/...
4
votes
1answer
41 views

Need 410 error code for htaccess on Joomla site for a limited number of pages

I have a Joomla 3.9.13 site, using Gantry 5.4.31. I have a limited number of articles I want to remove from my site, and instead of returning a 404 error I want to return a 410 error. I am not a ...
0
votes
0answers
19 views

Use .htaccess to prevent image hotlinking except for Google, Bing, Yahoo, and Facebook [duplicate]

Can anyone create a .htaccess hotlinking rule for me allowing Google all domains (.com, co.uk, co.in, .au etc.) + bing.com + yahoo.com + facebook.com I would do it using online hotlink htaccess ...
3
votes
2answers
101 views

How to prevent hotlinking for specific domains using .htaccess?

I'm being heavily spammed by image scraper sites. There are more than 150+ domains targeting my images & sending spammed links to my site. I just want to prevent hotlinking from them. I just want ...
1
vote
1answer
48 views

Use .htaccess to redirect to add .txt extension

I have a .txt file on my hosting and would like to redirect to it if somebody enters an specific website within their browser, e.g. example.com/webpage --> redirects to --> example.com/...
1
vote
1answer
76 views

Can certain pages load without “.html” extension, instead of whole site?

I set up my website so that all pages load without the .html extension, using the following code in the .htaccess file: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...
3
votes
2answers
99 views

How to set up htaccess to redirect all URLS to new domain?

So I have domain http://example.com. I want to setup htaccess to redirect all of these variations http://www.example.com http://example.com https://example.com/111 http://example.com/222 ... ...
0
votes
0answers
18 views

How to set up htaccess to redirect all URLS to new domain main page (no path)? [duplicate]

So I have domain http://example.com. I want to setup htaccess to redirect all of these variations http://www.example.com http://example.com https://example.com/111 http://example.com/222 ... ...
8
votes
5answers
39k views

How to verify what modules are active on my server?

While trying to solve a problem on my website, a recommendation about my .htaccess file I got was First of all, please check on the server for all the different modules if they are enabled, and ...
5
votes
3answers
1k views

Getting 301 redirect error in Google Webmaster Tools while using “change address”

So I'm moving my website from one domain to another. In this process I'm using the "change address" function in Google Webmaster Tools on my old-domain.com, "switching" it to / choosing my verified ...
2
votes
0answers
66 views

How do I redirect thousands of WordPress URLs to a subdirectory?

I have a WordPress website and it has almost 22,000 blog posts. It has been running with good SEO for the past 6 years. The contents are scattered in almost all social media and backlinked in a lot ...
4
votes
1answer
73 views

Link from a Wordpress page to a password protected non-Wordpress page on a subdirectory

I have a Wordpress site which contains a link to a non-WordPress (i.e. pure Html) page sitting on a subdirectory of the same domain. It all works fine at the moment but now I wish to password protect ...
2
votes
1answer
67 views

Google Sites: 301 Redirect broken links to the home page

Several months ago, I migrated my domain from GoDaddy to Google Domains and now use Google Sites. Several broken links from the old GoDaddy webpage highly ranked on Google Search persist. I would ...
2
votes
2answers
35 views

Redirect 404 Sub Directories to the equivalent sub-domain

We're moving thousands of sub directories, to a sub domain. The exact same slug, but its a sub domain now. All of these sub directories are going to cause a 404. Using htaccess, how can I take the ...
2
votes
1answer
119 views

Use .htaccess to remove a directory and .php extension from the URL

I am running a Wordpress website, but I have some folders not related to the wordpress CMS, but in the same directory where all Wordpress folders are. The .htaccess in root WP folder has its standard ...
2
votes
1answer
43 views

htaccess redirect each CSS URL to another CSS file

I want to redirect every URL which ends with .css to a specific CSS file. This is because we are using Mouseflow for analysis and sometimes we generate a new CSS file. Mouseflow is then trying to ...
1
vote
0answers
24 views

Cloudflare + Forced SSL + auth on directory

I hope I'm asking in the right area. Here's what I have. Apache 2.4.18 on Ubuntu 16.04 server. I have my main website in a vhost, call it domain.com. This is proxied through CloudFlare. I also ...
2
votes
1answer
32 views

htaccess rewriterule not working for old urls for site rebuild

I am struggling to get the rewrite rules working in .htaccess for search links on a property rental website I am working on. The old links are like this: example.com/index.php?proptype=Villa&...
0
votes
1answer
71 views

How can I resolve htaccess causing social media bots to see 404 response even though the page displays correctly?

I use the below htaccess code which appears to function correctly to rewrite URLS, however when a page is shared to social networks or scanned by bots like AHREFs, they all return 404 yet the pages at ...
1
vote
1answer
31 views

How redirect directly to the final domain URL rather than a chain through variations of `www` and `https`?

When I type example.com in the URL it first redirects to http://example.com then to https://example.com and finally to the https://www.example.com (the original address). Why doesn't it straight away ...
4
votes
1answer
363 views

Deny access to all PHP files using FilesMatch, but make an exception for one file

Currently, using htaccess I am denying access to any PHP file in a directory, but not the JS, PNG, CSS files in the same directory. <FilesMatch "\.php$"> Order deny,allow Deny from all </...
2
votes
1answer
41 views

Redirecting index.html to root + folder index.html to root folder? (multilingual)

I have example.com page. I want a homepage without index.html (example.com/index.html -> example.com) RewriteEngine On RewriteRule ^index\.html$ / [R=301,L] RewriteRule ^(.*)/index\.html$ /$1/ [R=301,...
8
votes
1answer
8k views

.htaccess rewrite URL leads to missing CSS

I am trying to make my url from this: example.com/view.php?id=15 To this: example.com/watch/15 My code in .htaccess is as follows: Options -Indexes Options +FollowSymlinks RewriteEngine On ...
3
votes
1answer
52 views

What is the Cloudflare equivalent of these two .htaccess redirect rules?

I usually set up my sites to rewrite URLs in the following cases: All http traffic is redirected to https (and www), with a 301 All non-www traffic is redirected to www (and https), with a 301 In ....
1
vote
1answer
34 views

Using htaccess to redirect 301 for domain change

I am currently moving a domain from one to the other, this is not an HTTPS move but rather a move from exampleone.co.uk to exampletwo.co.uk. I am using this code: <IfModule mod_rewrite.c> ...
2
votes
1answer
65 views

.htaccess, redirect all to bye.php, even with more slashes, with exception

I need, in .htaccess, redirect all behind domain, but even with more slashes and with slash or no slash at the end, but with one exception. For example example.com/all/sites/should/redirect/to/one/...
3
votes
1answer
117 views

PDF files still indexed when X-Robots-Tag noindex set in .htaccess

I am trying to analyse the .htaccess file of a website, specifically the following piece of code: <FilesMatch ".pdf$"> <IfModule mod_headers.c> Header set X-Robots-Tag "noindex, noarchive,...
2
votes
1answer
42 views

Redirect hundreds of subdomains to the main domain with path forwarding, use .htaccess?

I want to redirect from a subdomain to domain along with URL path forwarding. Example: abc.example.com/products.html TO another.example/products.html The trailing URL should be preserved. We ...
2
votes
1answer
59 views

Block/allow access to certain PHP pages

I have a number of PHP scripts that are meant to be included into other PHP scripts, but otherwise should not be directly accessible to anyone via a Web browser. How do I block people from accessing ...
9
votes
10answers
24k views

Need to Stop Bots from Killing my Webserver

I am having EXTREME bot problems on the some of my websites within my hosting account. The bots utilize over 98% of my CPU resources and 99% of my bandwidth for my entire hosting account. These bots ...
3
votes
3answers
172 views

Switching domain from HTTPS to HTTP

I recently launched a new site on an existing domain, using new hosting. The previous site utilized HTTPS, the new site does not (just HTTP). The problem I ran into is that Google currently has the ...
1
vote
1answer
236 views

How can I change URL Letters from Upper to Lower case in htaccess for a specific folder?

I'm a bit stuck, so thank you for any help! In short I'm trying to convert either of the two examples (I have mod_rewrite from the first to the second already). I only want this to apply to the ...
3
votes
1answer
36 views

WP Apache .htaccess redirect .com traffic to .co.uk Issue

I have a website I am looking to redirect .com traffic to .co.uk. For the moment, when I navigate to https://example.com, it redirects to https://www.example.co.uk and displays as such in the address ...
2
votes
3answers
146 views

Using htaccess to force HTTPS doesn't work

NEW EDIT 28/oct/19 → I edited the .htaccess file as you said AddHandler x-mapp-php5.5 .php # HTTP to HTTPS redirect RewriteCond %{SERVER_PORT} 80 RewriteRule (.*) https://www.bebechan.net/$1 [R=301,...