Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
3
votes
1answer
31 views

.htaccess rewrite rules for nonsense URLs

I have a number of rules governing the URLs on my main website & it's a pretty nice setup. There is an unintended consequence that has come up though. My latest addition cleans up a bunch of 500 ...
1
vote
1answer
35 views

How to remove slash from directory when there are more rewrite rules in the subdirectories on Apache?

I've an Angular applicaion in multiple languages. After the build process there exist a distribution for each language. These are put onto the server in locale directories: /en/index.html /fr/index....
1
vote
1answer
38 views

How to add trailing slashes to links in my pages from .htaccess in addition to the redirects I've implemented?

I've recently appended the trailing slash at the end of the URL by using this .htaccess code: #add trailing slashes RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^...
0
votes
0answers
23 views

2 languages redirect htaccess

I have a one page website in 2 languages (root is empty): https://example.com/en/ https://example.com/pl/ All visitors using Polish language in browser should be redirected to: https://example.com/...
2
votes
1answer
56 views

403 Forbidden error for Wordpress login after whitelisting Cloudflare IPs in htaccess

I’m using Cloudflare nameservers and tried to whitelist Cloudflare IPs through htaccess file, but it results in a 403 Forbidden error for my Wordpress login. Here are the directives I used in ...
0
votes
0answers
12 views

apache .htacess redirect to treat root domain with or withought / as a single page not 2 page [duplicate]

I have developed a dynamic PHP website and code is written in core PHP (NO CMS or Framework used). When I am checking with SEO tools it is saying duplicate content for https://sattamatkaa.in/ and ...
1
vote
1answer
35 views

mod_rewrite rule for new pages that keep wildcard subdomains

I've read everything I could and can't figure this out. I need a simple page redirect that keeps the original subdomain. We have several stores on their own subdomains with identical product page ...
1
vote
1answer
34 views

Prevent apache from using machine host name

In our office, we have a public facing server whose machine hostname is server16. We want Apache to only respond to requests on server.example.com. We have a VirtualHost entry with ServerName server....
1
vote
1answer
35 views

How to rename multiple files using .htaccess

I need to rename many jpg files. For expamle: warszawa_1.jpg -> wars_1.jpg, warszawa_2.jpg -> wars_2.jpg I created in the .htaccess file something like that: Redirect 301 /img/warszawa_1....
1
vote
1answer
258 views

htaccess force HTTPS to main domain and all subdomains

I have a server with a main domain, and several subdomains. There is independent wordpress sites/installs on each of the subdomains, and also one on the main domain. (I know about multisite, but they'...
2
votes
1answer
39 views

Can I rewrite to a redirected URL using .htaccess file?

I have a page A. I want to have a page B which is served as a rewrite of page A using .htaccess. Is it possible to redirect page A to page B from .htaccess or is it going to go into an endless loop?
0
votes
0answers
12 views

Error caching static js files in my htaccess file. What does this error mean? [duplicate]

I have this in my .htaccess file: <IfModule mod_expires.c> ExpiresActive on # Perhaps better to whitelist expires rules? Perhaps. ExpiresDefault "access plus 1 ...
1
vote
1answer
54 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
31 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....
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 ...
2
votes
1answer
65 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 ...
1
vote
0answers
32 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 ...
1
vote
0answers
134 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 ...
2
votes
1answer
90 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
53 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> ...
3
votes
1answer
55 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
40 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
2answers
148 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 ...
2
votes
1answer
46 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
1answer
101 views

What should I do about penalized websites that have been 301 redirected to mine?

Someone is doing a negative SEO attack on my site 301 redirecting toxic sites to my site. I have done research and nobody online seems to have an answer. Would disavowing the domain doing the 301 ...
3
votes
1answer
179 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 ...
0
votes
0answers
21 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 ...
2
votes
1answer
41 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/...
3
votes
2answers
251 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 ...
4
votes
1answer
71 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

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 ... ...
3
votes
2answers
120 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 ... ...
4
votes
1answer
102 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
361 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
78 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 ...
1
vote
0answers
44 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
0answers
77 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 ...
2
votes
1answer
43 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&...
2
votes
1answer
1k 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 ...
1
vote
1answer
33 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 ...
2
votes
1answer
91 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 ...
4
votes
1answer
1k 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
340 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,...
2
votes
1answer
75 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
71 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/...
2
votes
1answer
66 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 ...
3
votes
1answer
175 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,...
1
vote
1answer
825 views

htaccess redirect based on referrer URL string

I have a 3rd party who POST's to a specific page on my website. They post a file and my site does some wizardry with the contents of that file. The request URL would be for example https://example....
1
vote
1answer
66 views

subdirectory htaccess url rewrites

I have a project with this skimmed structure: -proj -----pages ---------example -------------pages -------------.htaccess ---------.htaccess I managed to get it working so that all url's go to /...
1
vote
2answers
22 views

Why doesn't my .htaccess file redirect my old WordPress permalink structure?

About 9 months ago i changed my permalink structure in WordPress from the domain.com/year/month/article-name format to the domain.com/article-name one. I hired someone to do the rewrite rules for ...

1
2
3 4 5
30