Questions tagged [htaccess]
Directory-level configuration file found mostly on Apache web servers
1,650
questions
1
vote
1
answer
24
views
.htaccess redirect php WHMCS cart ID
For WHMCS I am trying to redirect products to another ID and subdomain.
How can I create a .htaccess that will redirect
https://www.example.com/clients/cart.php?a=add&pid=17
to
https://clients....
1
vote
1
answer
28
views
Redirect 301 a URL already created by a rewrite rule in .htaccess
I'm creating SEO friendly URLs with rewrites in .htaccess.
Now I need to redirect (301) a couple of these rewrites, and have no idea how to do that.
These lines:
Options +FollowSymLinks
RewriteEngine ...
2
votes
3
answers
63
views
Why do I have to enter basic authentication credentials twice for WordPress with .htaccess?
I protect the wp-login.php file via my .htaccess file:
<Files wp-login.php>
AuthName "Admin-Bereich"
AuthType Basic
AuthUserFile /*path*/htdocs/.htpasswd
require valid-user
</Files&...
1
vote
0
answers
14
views
Is RewriteMod for WordPress site: site.ro -> site.com/?lang=ro possible?
I'm not much of a WordPress specialist - is it possible to redirect new domain to the same site, but with ?lang=ro query parameter so it shows the old site with selected language?
Result I want:
site....
1
vote
1
answer
37
views
WordPress doesn't identify the subfolder
I have a subfolder with a separate WordPress running on it. When I click on a link which should lead to the destination in the new website (the subfolder) it reads everything except the mentioned ...
0
votes
1
answer
51
views
Why . htaccess file is necessary?
Actually some hosting provider disable
. htaccess file in window hosting.
Is this necessary file?
If this file is necessary then how to enable it?
1
vote
1
answer
35
views
If .htaccess redirects domainroot to a localized start page, should the domain root (which should be canonical) be in the sitemap.xml?
When you host a webpage, e.g., https://mydomain.example and .htaccess already takes care of the rewrite from www to without www and from http to https and it is also rewriting with RewriteRule ^$ ...
4
votes
1
answer
36
views
How do I find if any website still links to one of my pages?
not to be confused, I'm not looking for backlinks check. I took over a site that has more than 10.000 redirects inside htaccess file.
Those redirects were made 2 years ago when the website platform ...
1
vote
1
answer
79
views
Website not working due to htaccess
My website was fine (apologies in advance for not being a webmaster or developer) until SSL was enforced through hosting platform - a 500 error code/page showing internal server error. Spoke to ...
4
votes
1
answer
181
views
Handling # uri fragments as regular requests
So I have a one-page website with multiple sections and IDs. Right now, in the nav, I have it going to #about to jump them down to a section with ID=about
But I want the user to be able to go to ...
0
votes
0
answers
63
views
htaccess: differentiate between directory and directory with query parameters
I have a little PHP framework like this:
?page=page-name
?page=page-name%slug=slug-name (in the case of plural list pages)
I'm trying to pretty her up.
/exercises → ?page=exercises
/exercises/...
4
votes
1
answer
50
views
Will changing URLs with .htaccess impact my SEO negatively?
Basically, I have URL like www.example.com/month/day/name-of-post.
What I want to do is to change the month/day to blog/month (or just /blog/) for continuity.
I have a WordPress and the pages are ...
0
votes
0
answers
23
views
Retain URL With Slashes And Redirect To File
This has probably been answered several times but I can quite find the exact answer im looking for, I've tried a variety of examples but none do what I need.
I'm trying to mask a URL to a one file ...
0
votes
0
answers
31
views
SSL DV certificate not working uniformly across browsers, ISP and OS
I purchased SSL certificate through Namecheap.
I am using Windows 11 OS, with BSNL Internet Service Operator(wifi) with Firefox v16, Microsoft Edge, Chrome v106 as browsers and iPad OS version 16 and ...
1
vote
1
answer
41
views
Can I efficiently write a redirect using .htaccess if domain stays the same, but new website has slightly different url structure?
I have an old site with thousands of products and some SEO ranking and I wanted to redirect URLs using .htaccess, hopefully without manually writing thousands of 301 redirect entries.
The domain stays ...
1
vote
2
answers
63
views
First website and losing hope with .htaccess and regex. I want to manipulate multiple things
Last time I used regex was to manipulate some BGP routes and it didn't go well. I don't expect anyone to write me a full .htaccess file, but: in which order would you write the lines? Should there be ...
2
votes
0
answers
73
views
Obscuring sub-domain
I have a site that is for a realtor and its URL is say, homesforsale.example but the actual listings are housed within an MLS/IDX system that is currently set to search.homesforsale.example. The ...
2
votes
1
answer
43
views
How to decrease unwanted traffic after malware attack?
After malware attack on my website I'm seeing more than 20000 get requests every day which are pointing to non existent places on my server. Those addresses were valid during the attack and were ...
2
votes
1
answer
44
views
How to rewrite a request to different files based on the domain name in ".htaccess"?
I run the website https://www.1.example. The contents of my .htaccess file are as follows:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ \...
2
votes
1
answer
48
views
Create a rewrite rule to prevent a file from appearing except on one subdomain
I have wildcard hosting set up on *.example.com, and I’d like to have a certain file appear on one specific subdomain only. I'd like to create a rewrite rule that prevents it from appearing on the ...
4
votes
1
answer
262
views
Modify rewrite rule to match ONLY directories, NOT directories AND files
I have the following rule in my .htaccess file:
RewriteRule ^[^/].*/(dir1|dir2|dir3)(.+) $1$2 [QSA]
It works great for the directories except sometimes it conflicts with files.
How can I modify this ...
5
votes
1
answer
127
views
Htaccess Hotlinking Prevention: Exclude a specific image from rule
I have a working hotlinking prevention in the .htaccess. Everything works fine. However, I use an image of my website in email signature. After the hotlinking prevention, this image is now displayed ...
3
votes
0
answers
84
views
Automatic display of WebP images instead of JPG images via Htaccess
I use Wordpress, the plugin "EWWW Image Optimizer" creates from JPG images automatically also WebP versions (example: From the image image.jpg is also an image image.jpg.webp created). The ...
4
votes
2
answers
103
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 ...
1
vote
0
answers
37
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 ...
1
vote
1
answer
42
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 ...
3
votes
0
answers
133
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 ...
0
votes
0
answers
42
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 ...
3
votes
1
answer
64
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://...
3
votes
0
answers
73
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 ...
8
votes
1
answer
998
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 -...
0
votes
0
answers
69
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 ...
0
votes
0
answers
64
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 ...
2
votes
1
answer
73
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 ^(....
1
vote
1
answer
342
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://...
3
votes
2
answers
29
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 ...
1
vote
1
answer
275
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 ?
2
votes
1
answer
60
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 /...
3
votes
1
answer
272
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 ...
2
votes
1
answer
127
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 ...
2
votes
0
answers
91
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, ...
0
votes
1
answer
43
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 ...
2
votes
1
answer
295
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 ...
2
votes
1
answer
300
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 ...
1
vote
1
answer
253
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 ...
0
votes
0
answers
172
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 ...
1
vote
0
answers
431
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 ...
0
votes
0
answers
49
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....
0
votes
1
answer
587
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]...
0
votes
1
answer
52
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, ...