Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [htaccess]

Directory-level configuration file found mostly on Apache web servers

0
votes
1answer
28 views

Redirect to remove everything after the second slash (first directory)

I'm trying to redirect a lot of pages on a website I own. There are a few pages indexed and I need to fix them for example: /vloerafwerking/projecttapijt/raamafwerking/ needs to go to /vloerafwerking/...
0
votes
0answers
21 views

.htaccess clean url to GET variable with WordPress

I'm struggling to get a .htaccess rule to work. I'm trying to cleanup a URL for a WordPress site. Instead of /illustration?rid=123, I'd like /illustration/123. I've tried solutions from many of the ...
1
vote
1answer
33 views

Add Trailing Slash for certain page types

I would like to add a trailing slash for certain static page types like .html, .asp and .pdf. I tried the following code in .htaccess but it is adding a trailing slash to all types of links. # Force ...
1
vote
1answer
11 views

Don't allow access to example.com/image/pic.jpg using htaccess

I have two domains for the same website. example.com and example2.com . I don't want the /image/pic.jpg to be accessible for the example.com It means, if someone try to visit example.com/image/pic....
0
votes
0answers
12 views

How to enable .htaccess Gzip? [duplicate]

#Gzip <ifmodule mod_deflate.c> # compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/...
0
votes
0answers
16 views

Redirect IP address to domain using .htaccess [duplicate]

I tried the following .htaccess code to redirect the IP address of my VPS server to my domain, but despite of all efforts it keeps resulting in a 404 error: RewriteEngine on RewriteCond %{HTTP_HOST} ^...
1
vote
1answer
24 views

htaccess rule doesn't work - NET::ERR_CERT_COMMON_NAME_INVALID

This URL: https://mqgmodas.com/rebajas/ Into the .htaccess I have: Redirect 301 https://mqgmodas.com/rebajas/ https://masqguapas.com/rebajas/ Also I have a redirection in my control panel saying ...
3
votes
2answers
19k views

Wild card redirection for HTTPS and Non-www version

I want to enable SSL for my main website and sub-domain websites. For SEO reasons, I need to redirect HTTP requests to HTTPS requests. I think I should do that using a wild card redirect in my ....
0
votes
0answers
25 views

Edit htaccess file to remove the slash at the end without disturbing https settings [duplicate]

My website URL has a slash at its end and appears like this https://mywebsite.com/ Since search engine reads https://mywebsite.com/ and https://mywebsite.com as two different URLs, I want to ...
5
votes
2answers
2k views

How can I serve all resources under HTTPS instead of HTTP without changing their URLs in the HTML code

I know that by using an .htaccess file I can redirect everyone to https://. However, my SSL certificate complains if all the content isn't served under HTTPS. Is there a way to convert all the ...
3
votes
0answers
31 views

Why are my HTML resources re-downloading despite having an expiration date a month in the future?

I have set the expiration information for my resources in the .htaccess file as shown below: <IfModule mod_expires.c> ExpiresActive on ExpiresByType image/jpeg "access plus 1 month" ...
2
votes
1answer
42 views

Return 410 gone status code for URLs containing same characters in .htaccess

My website was hit by the pharma spam attack which created hundreds of URLs, all of which contain the last 5 characters -1234.pdf. So that Google and other search engines will remove these quicker, ...
2
votes
1answer
288 views

Is my .htaccess settings hurting SEO?

I have a site that I have redirecting to HTTPS. I do this to leverage wildcard SSL for my password protected pages. Everything seems to work fine with testing. For example, whether you type in HTTP or ...
1
vote
1answer
36 views

htaccess category seo url redirecting to 404 page in localhost [closed]

I am trying to edit my htaccess. All urls working fine on server, but same htaccess setup redirecting category/cat_name/ url to 404 page without giving any error. all other urls working fine accept ...
2
votes
2answers
2k views

Redirect all traffic to construction page except my IP in .htaccess

The title pretty much says it all. I want to direct all traffic to an under construction page except for traffic originating from my IP address so I can move a large development site into production ...
1
vote
1answer
25 views

how to redirect lower case to upercase

I have a WordPress blog and I made subfolder like this https://example.com/Tourism but when I open this URL with lowercase "t" it shows me 404 not found error: https://example.com/tourism this ...
0
votes
2answers
47 views

301 redirect in the htaccess file issues

This is driving me crazy, can anybody tell me why this 301 redirect does not work. I just get a 404 error with the old /about page. Here is the code for info: {ENV:WPR_SSL}.html%{ENV:WPR_ENC}" -f ...
1
vote
3answers
75 views

When I have multiple .htaccess files between several sites, which is the active one?

I have 4 sites hosted with the same ISP. The sites were modified endless times, and now, I have several .htaccess files. One of the is at the main root. The others are spread in different places. For ...
2
votes
1answer
37 views

Redirecting /page/*/ to the home page in .htaccess

My problem is that my homepage exists on https://www.example.com/page/2/, /3/, /4/ and so on, it still exists on /1000/. Same duplicate page versions exists on /about and and /contact page of my site. ...
2
votes
1answer
74 views

.htaccess redirect with all parameters

I have a simple rule in the .htaccess file, to redirect all requests to inwork.php: RewriteRule .* php/inwork.php?refpage=%{REQUEST_URI} [L] But all parameters are missing. For the request http://...
1
vote
1answer
54 views

.htaccess rewrite conditions for https:// pre tag subdomains

I need some extra code in my .htaccess file that configures this HTTP request for HTTPS too! <ifmodule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.example\.com RewriteRule ^...
1
vote
4answers
11k views

Remove folder name from rewritten URLs

Consider this URL: http://example.com/gallery/20141111-some-title In this URL I want to hide gallery/: http://example.com/20141111-some-title How can I achieve this using mod_rewrite? I used ...
2
votes
1answer
88 views

.htaccess - How to properly disable the execution of scripts in a folder?

I have this folder path: pulic_html/user/269851516/in the folder /user/ i have many subfolders that is created when the user create a account, and they can upload avatars to this folder, i want to ...
5
votes
1answer
3k views

What are the most commonly used and basic Apache htaccess redirects?

This question is here so we can offer users who are looking for information on how to make one or more common or basic redirects in Apache using the htaccess file. All future questions pertaining to ...
0
votes
2answers
40 views

htaccess - Blocking IPs - Hidden and / or spoofing(?)

.About a month ago my website was hacked. I was alerted to that by Google Adwords because a random scan of my site indicated that it had inappropriate content and / or links to inappropriate content ...
1
vote
2answers
74 views

How secure is an .htaccess file?

I am creating a new website and I want to make it as secure as possible. I was preparing to do some things with .htaccess and I'm semi-concerned about the security level it provides. Can someone (ex: ...
5
votes
3answers
462 views

301 redirects for /blog to blog subdomain not working

I just created a new subdomain for my blog so blog.example.com - it used to be www.example.com/blog so I am now trying to write 301 redirects from all my old /blog posts to the new blog.example.com ...
1
vote
1answer
31 views

How is the mapping done from …/script.php?one,1 to …/script/one/2?

There is a PHP script which evaluates one or two parameters via QUERY_STRING. This script should process the parameters via QUERY_PATH. The PHP file type should be omitted. Request of the form https:/...
1
vote
3answers
1k views

How do I force a www subdomain on both HTTPS and HTTP?

For whatever reason I can’t seem to get this right. I’ve looked at many examples on here and on the Apache website. I’m trying to force www.example.com instead of example.com on both HTTP and HTTPS, ...
1
vote
1answer
50 views

How to redirect all url to https except one?

# Go to https if not on firmware RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} !^/firmware$ [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] # Go to http if you are on firmware ...
2
votes
1answer
27 views

Problem with [R=301]

Some of my RewriteRules don't work if i put the [R=301]. why this don't work? RewriteRule ^sitemap\.xml$ sitemap.php [R=301,L] It shows a Forbidden error when i try to access the URL https://example....
2
votes
1answer
31 views

Rewriterule redirects to URL and shows different URL?

I've a website hosted on an Apache server which hosts other domains. Therefore, I can't access the Apache configuration. On our website, I've several domains. For one of them (domain example.com), I'...
14
votes
2answers
5k views

Can .htaccess slow down a site?

I'm working with a client on an e-commerce website. I implemented clean URLs using .htaccess. I also used .htaccess to solve canonical issues such as redirecting www to non-www and removing index.php ...
2
votes
2answers
284 views

Redirect loop in .htaccess when removing trailing slash

I have the following .htaccess file: AddDefaultCharset utf-8 RewriteEngine on Options +SymLinksIfOwnerMatch RewriteBase / # redirect all www-requests to no-www # - RewriteCond %{HTTP_HOST} ^www\....
3
votes
1answer
900 views

Redirect all pages within subdirectory to new page

After redoing my webshop, I need to redirect every URL within a certain directoy to a new page. All URLs beginning ith example.com/shop/... should be redirected to the page located at example.com/...
1
vote
0answers
28 views

Infinite redirect loop with IIS 8.5 Drupal

After configuring my website, i stuck in a infinite redirect loop. I have 6 domains, example.com is main domain. example1.com, ..., example5.com are forwarding to example.com. Doesn't matter which ...
3
votes
1answer
42 views

Multiple rules to rewrite the url

Why both rules don't work together and how can i fix it? Only the first one works... I think that there's a conflict between the two rules, but i did not found a solution yet ?p= is the querystring i ...
3
votes
1answer
61 views

Hotlink Protection compatible with Google AMP pages

I'm trying to create HTACCESS Hotlink Protection on my site but I'd like all Google top level domains (.com., .co.in, .co.uk, etc) to be able to access my files, so that visitors to the Google AMP ...
1
vote
0answers
30 views

How to allow Google fonts to be cached for more than one day?

I tried this code below, but I still see the message on Google Insights that the fonts have a expiration of 1d. AddType application/vnd.ms-fontobject .eot AddType application/x-font-ttf .ttf AddType ...
3
votes
1answer
51 views

Non WWW redirect to WWW and non SSL to SSL - htaccess

I'm trying to redirect my Wordpress site from non www to WWW and non SSL to SSL permamently. Here's the code I'm using: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://%{...
3
votes
1answer
34 views

Can I block Tor users from sending spam on my form?

Can I use .htaccess to kill any message coming from a Tor IP, or should I make a script on my mailer? I've got $IP = $_SERVER['REMOTE_HOST'] ?: gethostbyaddr($_SERVER['REMOTE_ADDR']); and I checked ...
1
vote
1answer
24 views

.htaccess - redirect the contents of a subdirectory of old domain to new domain (WordPress) [duplicate]

I have problems with the redirection of my old website to our new website under a new domain. The old website was created with Wordpress and the simple redirect 301 was successful. However, some pages ...
1
vote
1answer
103 views

Convert Base64 in .htaccess

My Line is as under in .htaccess Header set Content-Security-Policy "script-src 'self' 'nonce-%{UNIQUE_ID}e'; style-src 'self' 'nonce-%{UNIQUE_ID}e';" Please let me know how to convert %{UNIQUE_ID}e ...
4
votes
3answers
292 views

How to use a RewriteRule and Redirect 301 at the same time?

I have my Url with multiple parameters: mydomain.com/?vote.php?ranking=parameter1&lang=parameter2&period=parameter3&provider=parameter4 but I would like to change my urls to SEO friendly....
2
votes
2answers
74 views

How to show 410 Gone status for subdomains that are already been deleted

I bought an auctioned domain to build my new project, from my analysis with Ahrefs, people that were behind this domain had a subdomain called "forum" for their forum, and somehow they didn't know how ...
2
votes
4answers
24k views

How do I do URL re-writes on Plesk?

I am very new to URL re-writing and I am using Plesk which is window-based web server, hence I can't use Apache's mod_Rewrite. Can anyone tell me what is the proper procedure for this?
1
vote
4answers
2k views

How can I redirect %26 in URLs to %2526 using a .htaccess rule?

I would like .htaccess to redirect: example.com/something_%26_else to example.com/something_%2526_else I'm importing a bunch of pages that have ampersands in the title from MediaWiki. These are ...
1
vote
1answer
284 views

RewriteEngine .htaccess rules end up redirecting to example.net/https:/example.net

I'm starting to learn about the Apache .htaccess and I have some issues in my website... RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{...
4
votes
2answers
3k views

Remove query string from 301 redirect URL

I'm having some trouble with redirects and I haven't been able to get this to work. I want to make the following http://www.example.com/seasonal/christmas?p=15 redirect to http://www.example.com/...
3
votes
1answer
53 views

How to redirect a specific search result using .htaccess

When searching for "interesting people" the search results page of my website is https://example.com/?s=interesting+people&submit.x=0&submit.y=0 Instead of displaying that search results page ...