We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

Filter by
Sorted by
Tagged with
4
votes
1answer
50 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
292 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
55 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
30 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
723 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
329 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
51 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
688 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
1k 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
487 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
24 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
130 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
757 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
39 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
652 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
42 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
35 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
981 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
3k 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
1k 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
878 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
328 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
1k 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
764 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
658 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
48 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
40 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
685 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
37 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 ...
3
votes
1answer
428 views

Are there any tools in Google Search Console for removing URLs with 301 redirects?

In Google Search Console, I am getting 15-20 all different URLs in 404 section which is not in proper format(this URL is too old around 6-7 years and there is no 'Linked from' for this URLs). I want ...
0
votes
1answer
46 views

Deprecating old URLs using htaccess

Currently I have this in my htaccess file: RewriteEngine on RewriteRule ^chart-(.*)\.php$ ./keyboard-chart.php?seo=$1 [QSA] RewriteRule ^keyboard-diagram-(.*)\.php$ ./keyboard-chart.php?...
2
votes
2answers
445 views

Robots.txt to disallow on multi level subdomains

I've got a server, where I have multiple development projects for clients. While developing, each instance lives on client.dev.example.com. I need to stop crawlers from crawling the development ...
1
vote
1answer
1k views

Force non-www https mode for a dirctory and its sub-folders

My root website (example.com) and its folder (example.com/folder) have two different CMS (Opencart for example.com and WordPress for example.com/folder). I use this code in example.com to force non-...
3
votes
3answers
676 views

Blocking bad bots in .htacess - should I add a BLOCK list or ALLOW list?

I got my Siteground hosting account suspended yesterday due to the allowed CPU overage. Besides recommendation to disable or control the WP heartbeat API, I was also recommended to block bad bots and ...
1
vote
2answers
2k views

How to redirect all pages in /directory/ to webpage with htaccess

I am trying to redirect all pages on my site in one directory to a specific page using htaccess. Example anything like example.com/forums/ example.com/forums/pages example.com/forums/subdirectory/ ...
4
votes
1answer
5k views

What does this htaccess file do in this configuration?

I've never seen this configuration in .htaccess. This comes from my site that currently reset. I have no SSL certificate installed, but I remember seeing these names on previous certs though. So does ...
1
vote
0answers
116 views

Mod_Security false positive, how can I whitelist?

I am getting the following error while I am trying to create a web service. How can I white list this user agent? I am not really able to understand the following error message. [error] [client ...
1
vote
0answers
246 views

.htaccess How to redirect some specific pages, then a blanket rule to new domain?

I am creating a new website on a new domain, and doing page-to-page redirects from the old website for (A) all static pages, as well as (B) all blog posts. A) The static pages follow a new URL ...
2
votes
0answers
412 views

.htaccess for two languages and corresponding redirect for every page based on accept-language

I have a website www.example.es, with this structure: www.example.es index.php 404.html somepage.html www.example.es/en index.php 404.html somepage.html I want to redirect any language but es to ...
3
votes
4answers
124 views

Hold my hand through my htaccess http to https redirects

I've been researching the best way to handle my htaccess file in order to switch from http requests to https and I've seen everything from basing requests off server ports, using server name requests ...
1
vote
1answer
185 views

How to use htaccess file for site migration?

We are doing a site migration. The protocol will change from HTTP to HTTPS. The server IP will differ (but in the same region), as the web agency says we can not have the same domain on two IPs. So ...
0
votes
2answers
82 views

General questions on operation of SSL secured sites [closed]

I am trying to get some understanding on differences between unsecured (http:// accessed) and SSL secured (https://) websites on Apache servers. So I am not trying to solve a specific problem right ...
2
votes
1answer
310 views

.htaccess - how do i redirect TLDs?

I'm currently using my .htaccess to force all HTTP requests to HTTPS, and that is working very well. However I would also like to redirect some TLDs. For example - http(s)://(www.)example.info -> ...
1
vote
1answer
48 views

.htaccess Rewrite whole dir contents to another

I am trying to rewrite the whole contents of a directory to the home url. so, if someone visits www.example.com/bnn27sh32j@d299/gold it should take them to www.example.com/gold I have tried: ...
1
vote
3answers
153 views

Help with HTACCESS redirection to HTTPS

I have inherited a web app. It's running fine. But it's using HTTP, not HTTPS. This is the .HTACCESS file: Options +FollowSymLinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ ...
0
votes
1answer
384 views

htaccess force HTTPS except two pages

I would like to force HTTPS (SSL) on every page except /es-ES/calculador-cuatro-pilares-destino-bazi.html or /en-US/bazi-calculator.html. How can I do that? I am using Apache HTTP Server (ver 2.2.x). ...
1
vote
0answers
114 views

Trouble with .htaccess rewriting .png/.php [closed]

I'm currently creating a "dynamic signature" for a forum or email signature. The php code writes perfectly fine onto an image with the .php page. When trying to access the .png file with the ...
1
vote
1answer
1k views

How to keep question mark in URL rewriting with a GET method?

I am trying to use URL rewriting to rewrite search-en.php?q=abc to pages-afficher-recherche.php?lang_abbreviation=en&q=abc and I did RewriteRule ^search-([a-zA-Z]{2})\.php\?q\=([a-zA-Z0-9_-]*...
2
votes
1answer
699 views

Return 410 Gone status for all .html files except a single one?

I bet there's at least one trivial solution to this problem, but I've yet to figure any of them out. In a nutshell, what I'm trying to achieve is, informing the search engines that there are no more ....
4
votes
1answer
724 views

How to add force https to htaccess file RewriteRule with _route_=$1

I inherited support for an Opencart 1.5 site which needs to have SSL enabled. I've edited the config.php files in / and admin/ and adding https:// to the URL is working in the browser and links are ...