Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

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

Password protect specific files on root of website

I have had a website running for a while and it has a small following. What I wish to do now is password protect some specific files that sit in the root directory. So I'd like the user not to see any ...
user avatar
  • 329
1 vote
0 answers
23 views

How to add url slugs when we don't know the slug? [closed]

I am currently making a url shortener site where I will be able to shorten links and then get the shortened URL and its unique id stored on the database. This(it isn't wholly ready) is where I have ...
user avatar
1 vote
1 answer
33 views

Old alternative domain names -- is it actually worth setting DNS to resolve at the website?

Someone noticed a problem with a site I manage in that somewhere all the old alternative domain names which we keep paying for were in the Google search results. Some problem had come up somewhere ...
user avatar
  • 165
2 votes
0 answers
23 views

Redirect URL if Only if Query String is Present with .htaccess Rule

I would like to redirect example.com/image.png?example, only if the ?example query string is present, to example.com/folder/folder/folder/new-image.png, and then for ?example to be removed from the ...
user avatar
0 votes
0 answers
18 views

Run .htaccess rule to remove trailing slash only if such a file exists

I have the following .htaccess rule but I would only like it to run it if a file exists without the removed trailing slash: RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] I use ...
user avatar
3 votes
1 answer
36 views

How to redirect all pages of Site A to home page of Site B using .htaccess to track referrals using Google UTM

I want 301 redirect from all pages of SiteA.example to Home Page of SiteB.example using .htaccess rewrite rule, Since I am not PHP guy I am not sure if below rule is correct RewriteRule ^(.*)$ https://...
user avatar
  • 749
2 votes
0 answers
51 views

PHP file triggers on every page load?

I've got a WordPress website that has a script which seems to be triggering every time any user loads a page. This PHP script is very simple (less than 25 lines) and is meant to be an API endpoint, so ...
user avatar
  • 121
8 votes
1 answer
951 views

Does adding a huge list of bots on .htaccess slow the site down?

This huge list of known bad bots is useful (GitHub) The list is huge with over 1,800 "known" bots, and I think it's a good thing to add this - I mean - why not? However, my main question is -...
user avatar
  • 405
0 votes
0 answers
25 views

Password Protecting Specific Files With Litespeed .htaccess

I know how to password protect all files in a specific folder, but I am planning on setting up a separate subdomain just for storing password protected files in the root directory. I would like all of ...
user avatar
0 votes
0 answers
22 views

Hide previous folder in URL with .htaccess [duplicate]

I have a URL structure like this: example.com/prefix/folder/ and I want to achieve this : example.com/folder/ For instance, I have cleanly organized my authentication folders into a proauth main ...
user avatar
2 votes
1 answer
58 views

.htaccess Wildcard Passthrough Redirect

I use a LiteSpeed web hosting server on *.example.com and I am currently using this code in my .htaccess file for it: RewriteEngine On RewriteCond %{HTTP_HOST} ^(.+)\.example\.com$ [NC] RewriteRule ^(....
user avatar
1 vote
1 answer
31 views

Rewrite three URL directories to corresponding PHP files and pass subdirectory as a parameter

I want to convert the following https://example.com/download-file/xyz https://example.com/download-code/abc https://example.com/developer/mno to https://example.com/download-file?name=xyz https://...
user avatar
3 votes
2 answers
22 views

Rules in .htaccess only if the requested URL is /wp-admin

I want these lines from my .htaccess to execute only if the URL is not /wp-admin: Header add Content-Security-Policy "default-src 'self';" Header add Content-Security-Policy "script-src ...
user avatar
1 vote
1 answer
57 views

Hide subfolders in URL with .htaccess

I have a URL structure like this: example.com/this/is/nice/index.php and I want achieve this: example.com/this/index.php How can I add a rule to hide the /is/ and /nice/ subfolders ?
user avatar
2 votes
1 answer
47 views

Apache htaccess detects disallowed method but does not return error page

I am trying to see if a custom error page can be sent to the browser when an invalid method is sent to the server. In my .htaccess is this: ErrorDocument 400 /errpages/httperror.php ErrorDocument 401 /...
user avatar
3 votes
1 answer
240 views

Duplicate Homepage in search results with different hash-bang URLs

I just realized that my homepage is present in google with three different URLs. https://www.example.com https://www.example.com/#!/page/2/ https://www.example.com/#!sweat-shirts So I guess I need to ...
user avatar
2 votes
1 answer
87 views

Create 301 redirects for subdomains from expired domain for SEO

I just bought an expired domains and there are lots of backlinks to different subdomains. I am planning to make a new blog on the domain and I want to get all the link juice. So I want to create a 301 ...
user avatar
1 vote
0 answers
46 views

How to 301 redirect site alias domain to a subdomain on the same hosting?

We have the following problem in Cpanel / htaccess file when trying to 301 redirect example.hu (alias) pages to example.com (subdomain) pages: Cpanel example.hu to example.com redirection is working, ...
user avatar
0 votes
1 answer
41 views

Problem displaying 'includes'

I am having a hard time figuring this out. I hadn't changed anything on the site before this, however my webhost (BlueHost) sometimes messes with my files. Anyway, I am not able to bring up anything ...
user avatar
  • 252
2 votes
1 answer
56 views

custom 404 page not work Apache/2.4.51 if missing is in a virtual subdirectory (Debian)

this is my first question here, I hope to find a solution. I have a problem with page 404 when the missing page is in a sub "virtual" directory, is used to pass a value to php, in ...
user avatar
2 votes
1 answer
126 views

Rewrite URL with one unnecessary parameter

I have the following URL examples. Example one is a URL without "amps" parameter: https://multilang:8890/uk/seconddoc.html/ there I have a 404 error. And an other one with that amps ...
user avatar
1 vote
1 answer
98 views

Redirect AMP Parameter To Its Permalink caught in Redirect loop

I have the same issue as mentioned on Redirect AMP Parameter To Its Permalink, the solution given by Mrwhite solved my problem and everything went fine # Redirect old "amp" URLs back to ...
user avatar
0 votes
0 answers
73 views

Unexplainable 301 redirect persists after redirect is deleted

I am using wordpress on a domain on my server and I am trying to configure redirects from a parked domain to my main domain. My main domain uses wordpress. My parked domain uses nothing (no wordpress ...
user avatar
0 votes
0 answers
135 views

.htaccess security headers for IONOS

I need to implement security headers for a website hosted by IONOS. I've used the following code, which works on sites hosted elsewhere, but not here. <IfModule mod_headers.c> Header set ...
user avatar
  • 109
0 votes
0 answers
34 views

I want to redirect 301 to an added query string

I do want to 301 redirect https://example.com/no/ and all the URLs from that catalogue with an added query string ?lang=no. For example will then url https://example.com/no/about/ be https://example....
user avatar
0 votes
1 answer
173 views

503 Service Temporarily Unavailable nginx [closed]

how to fix this issues: when i use www.dbahack.com it show me this message "503 Service Temporarily Unavailable nginx" here is my DNS from cloudflare: [![enter image description here][2]][2]...
user avatar
0 votes
1 answer
50 views

linking 404.htm to .htaccess

I have an old 2004 Dreamweaver website built on HTML. Tired of the analytics telling me I have a lot of 404s, I created a 404.htm page. How do I link the code in .htaccess to it so it will show up, ...
user avatar
2 votes
1 answer
38 views

Mapping category label url into new custom category permalink?

I migrated my old blog into WordPress, my old cms has a category URL structure like this one https://www.example.com/search/label/health?m=0?&max-results=8 https://www.example.com/search/label/...
user avatar
  • 45
2 votes
1 answer
135 views

Redirect AMP Parameter To Its Permalink

I have a similar situation as described in Handle "amp" in URLs from a now removed WordPress plugin the difference is I don't use custom post permalink /%postname%.html but just /%postname%...
user avatar
  • 23
2 votes
1 answer
78 views

Handle "amp" in URLs from a now removed WordPress plugin

i used an amp plugin earlier but then I disabled it. Now variations of leftover amp path leave me with a thousand of "not found" or extra additional URLs with amp parameters. https://www....
user avatar
  • 45
0 votes
0 answers
26 views

Show Different content to different users of same post [closed]

Suppose https://example.com/how-to-learn-seo is a post which is published and i want it to show this post content only to bots (google, bing, etc.) not to users. If a user visit then they will see a ...
user avatar
1 vote
1 answer
101 views

Test website can't be reached despite setting up DNS in local hosts file and adding a virtual host to Apache config

I am trying to set up a domain on my development machine so that I cant test slightly more complex htaccess rules. I am trying to set up example.city domain. Following what I find by googling, I have ...
user avatar
4 votes
1 answer
82 views

Why rewrite to index.php is not working on a wordpress site?

So my rewriterule is like RewriteRule ^test$ index.php [L] I tested it on https://htaccess.madewithlove.com?share=b0a9904b-1ec4-49cd-917c-36426ff6150a it works fine. I also tested it on live Joomla ...
user avatar
  • 485
2 votes
0 answers
35 views

Can I have a generic rule to map subdomains to directories?

I have these rulesets which are working. RewriteCond %{HTTPS} =on RewriteCond %{HTTP_HOST} ^www\.example\.city$ [NC] RewriteRule ^(.*)$ https://example.city/$1 [R=301,L] RewriteCond %{HTTPS} !=on ...
user avatar
1 vote
1 answer
52 views

How can I have either php or html file running - whichever exists

I have these two rules and they appear to be working. How can I combine them into one rule #Force hmtl extn RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.html -f RewriteRule ^(....
user avatar
1 vote
0 answers
30 views

.htaccess - Force SSL and dont show .html in URL

I have a website where i want to Force https to all visitors, and I also don't want the URL to show .html at the end. In Google Search Console and Bing Webmaster tool i get an "Redirect errror&...
user avatar
  • 11
1 vote
1 answer
469 views

htaccess for redirects and gone 410

I am facing a problem. THE Problem is that in google search there some spam links that are of type HTTP and I would like to return 410 for those urls that actually do not exist. but for people who ...
user avatar
  • 11
2 votes
1 answer
34 views

How do I get .app TLD to work with my .htaccess

I have a number of domains hosted on one server. I tried them as sub-domains but that was a failure. So I obtained new certificates and I have them configured as Add-On_Domains. They are all using ...
user avatar
2 votes
0 answers
21 views

I used a permanent 301 redirect and now want to use old domain again, is this bad SEO wise?

I have a blog that I wanted to professionalize it a bit more and moved from a personalized domain name (DomainA/subfolder) to a more professional domain name (DomainB). The blog is from 2015 and I ...
user avatar
2 votes
1 answer
63 views

Wordpress - Ignore a server directory containing index.html if being viewed in preview mode

I have wordpress installed on a root directory. Wordpress was often so slow, I created a node script which will look at all pages on the website, and a create a static directory for each one with an ...
user avatar
  • 123
2 votes
0 answers
28 views

.htaccess not redirecting me to correct place

I have a website which opens to /resources/Installer/index.php but the path I need it to open to is /Installer/index.php. I have asked my webhost to help but they have said they cannot help. I have ...
user avatar
6 votes
1 answer
1k views

Why is a link to www.example.software not working?

I have looked at some posts here, but they dont answer my problem. I have subdomains and addon-domains and not all of them have a certificate yet. So I cannot use a generic solution. my .htaccess is ...
user avatar
1 vote
2 answers
52 views

ahrefs site auditing reports a redirect chain that I cant't see. What's causing this?

ahrefs site auditing, reports a redirect chain that I cant't see. Surely, only the first ruleset should be activated. What's causing this ? domain http://www.example.software/ Redirect chain URLs ...
user avatar
3 votes
2 answers
49 views

How does the server remember logged in users on a password protected website via .htaccess?

So basically my question is just a technical one. We password protect our development server so that no duplicated content appears to google if we mirror an existing website. How does the server ...
user avatar
3 votes
1 answer
58 views

How are slashes added between htaccess mod_rewrite variables

I was looking at two different variants of redirects: RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=301] RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] And noticed that in the first ...
user avatar
4 votes
1 answer
81 views

htaccess - URL Rewrite to rewrite specific URLs but allow one subdir URL

We are using a CMS (Magento) where we are looking to have all of the current customer dashboard links redirect to the homepage, however when doing this with simple 301 rewrites, it unfortunately ...
user avatar
  • 185
2 votes
1 answer
116 views

How do I prevent access to an add-on domain as a subdirectory of the main domain?

I have my main domain as example.software. I used to have example.kiwi configured as a subdomain, but the hosting company could not get the certificate to work. They asked me to fork out more money ...
user avatar
2 votes
2 answers
96 views

Apache maintenance page htaccess without being overriden by subfolder

I want to perform a maintenance on my website, so wrote an htaccess (I do not own the server) to redirect users to a specific page. <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{...
user avatar
1 vote
0 answers
22 views

Browser appends a '?' to links on page, but the '?' does not appear in the source [closed]

I'm a little puzzled with the following problem: When I hover over a link a WordPress site I'm looking after, I can see that the URL is https://xxxxxxx.com/apply-now/? All the links on the page have ...
user avatar
0 votes
0 answers
23 views

Where a domain is mapped onto a subdomain, can the redirected url be hidden from the browser

I now have my main domain working fine. I have 5 other independent domains that I am trying to map onto my main domain as sub-domains. I also have a wild-card certificate to cover the 4 of those ...
user avatar

1
2 3 4 5
33