Questions tagged [htaccess]
Directory-level configuration file found mostly on Apache web servers
1,413
questions
19
votes
2answers
16k views
htaccess execution order and priority
Can anyone explain to me in what order apache executes .htaccess files residing in different levels of the same path and how the rewrite rules therein are prioritized?
For example, why doesn't the ...
17
votes
4answers
765 views
How do I implement URL rewriting in my .htaccess file?
I'd like to do some URL rewriting (Why? See this question.) so that instead of users seeing addresses like
labouseur.com/course-compilers.html
they can instead see and use simply
labouseur.com/...
16
votes
2answers
78k views
Font blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin'
we are experiencing this error in Google Chrome. We thought everything was set-up correct. But maybe not?
Font from origin http://skin.cdn.com has been blocked from
loading by Cross-Origin ...
15
votes
4answers
105k views
How to enable use of .htaccess in Apache on Ubuntu?
I'm trying to enable use of htaccess file in Ubuntu 14.04 (Apache 2.4.7).
I know that this question has many possible duplicates, but none of them helped me yet.
.htaccess
ErrorDocument 404 /404....
15
votes
4answers
645 views
Removing non-www support
I'm not an advocate of the no-www movement. I like the www because it adds as a buffer to distinguish between our public and private/static sites.
The problem is that with one of our sites, our ...
15
votes
2answers
3k views
Is it better to have an ErrorDocument 404 redirect back to the homepage or a standard 404 error page?
We run an ecommerce site that was setup by a third party ecommerce software provider, basic shop with product pages, basket and checkout.
The third party vendor set up the htaccess file so that if a ...
15
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 ...
14
votes
5answers
5k views
How can I stop a bot attack on my site?
I have a site (built with wordpress) that is currently under a bot attack (as best I can tell). A file is being requested over and over, and the referrer is (almost every time) turkyoutube.org/player/...
13
votes
1answer
50k views
How to pass GET parameters to rewritten URL?
I have an .htaccess rewrite rule like this:
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^search/(.*)$ search.php?q=$1
What this does is, if someone visits http:/...
13
votes
4answers
208 views
What are some resources for learning the ins and outs of .htaccess?
What are resources for learning the various things I can do with .htaccess?
12
votes
1answer
634 views
How are web applications like Tumblr, WordPress.com and Blogspot able to create subdomains for users so fast?
I am curious as to how web-applications are able to create sub-domains instantly for new users, for example, newuser.wordpress.com, or example.blogspot.com. If I need to create a new subdomain for a ...
12
votes
1answer
518 views
301 redirects for all except me
I want to have my site down for an hour and I was using
order Deny,Allow
Deny from all
Allow from my.ip.add.ress
but I don't like the default error page. Is there a 301 redirect where I can ...
12
votes
4answers
3k views
Blocking referral traffic
I am currently getting a massive amount of referral traffic to my site (Spam), that can sometime generate 1-2 GB worth of traffic per a day (which kinda sucks, when you have a 10GB limit from the ...
11
votes
4answers
3k views
Can the files robots.txt and sitemap.xml be dynamic through an .htaccess redirect?
I have a multilanguage and multidomain site. It runs through a unique CMS installation (Drupal), so I have a single root directory. So if I have a static robots.txt, there I only can show the files ...
11
votes
6answers
8k views
Forcing SSL and www in .htaccess
I'm looking for a way to force SSL and www.
I've been able to force both separately but together I keep running into redirection issues. The following code works when handling a URL in this format: ...
11
votes
2answers
946 views
Homemade URL shortener redirect conflicting with 301 redirects
I have a website which was originally built using classic ASP. About a year ago it was rewritten in PHP. This caused file extensions to change and some pages were moved to new locations within the ...
9
votes
10answers
24k views
Need to Stop Bots from Killing my Webserver
I am having EXTREME bot problems on the some of my websites within my hosting account. The bots utilize over 98% of my CPU resources and 99% of my bandwidth for my entire hosting account. These bots ...
9
votes
1answer
6k views
Alternative to .htaccess (due to bad performance)
I've been told that .htaccess should be avoided when possible, as it reduces the server performance and new servers disable it or just don't implement it any more. I don't know how true this is, but ...
8
votes
3answers
22k views
htaccess redirect non-www to www with SSL/HTTPS
I want a rewrite rule that redirects everything to https:// AND www.
For example http://example.com should be going to https://www.example.com
This is what I have:
RewriteEngine On
RewriteCond %{...
8
votes
3answers
241 views
I want to test major changes on my website without hurting SEO
I want to replace all my website files for new ones on the server and to test if they work alright but I don't want to be crawled while this is happening or if I am,
I don't want the crawler to be ...
8
votes
5answers
39k views
How to verify what modules are active on my server?
While trying to solve a problem on my website, a recommendation about my .htaccess file I got was
First of all, please check on the
server for all the different modules
if they are enabled, and ...
8
votes
1answer
8k views
.htaccess rewrite URL leads to missing CSS
I am trying to make my url from this:
example.com/view.php?id=15
To this:
example.com/watch/15
My code in .htaccess is as follows:
Options -Indexes
Options +FollowSymlinks
RewriteEngine On
...
8
votes
2answers
15k views
Extend depth of .htaccess to all subfolders and their children
I need to be able to use .htaccess in all subfolders for full depth. E.g. I have .htaccess in public_html folder:
\public_html\.htaccess
How I make it to work for the folder small as well?
\...
8
votes
1answer
412 views
Problem with .htaccess and mod_rewrite after moving site to new server
The site seems to draw the correct links but its not redirecting me to the correct view.
The same code works fine on the old server here http://ruse.systemio.net/q&a/.
The new server is here http:...
7
votes
2answers
30k views
How to redirect any URL to lowercase URL?
I am using:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://example.com/$1 [L,R=301]
<...
7
votes
3answers
4k views
Where do I create the file .htaccess, in order to serve my HTML5 cache manifest file correctly?
From a post on http://diveintohtml5.org/offline.html (Wayback Machine Copy)
Your cache manifest file can be
located anywhere on your web server,
but it must be served with the content
type ...
7
votes
4answers
15k views
How to Remove Extensions From, and Force the Trailing Slash at the End of URLs?
Example of current file structure:
example.com/foo.php
example.com/bar.html
example.com/directory/
example.com/directory/foo.php
example.com/directory/bar.html
example.com/cgi-bin/directory/...
7
votes
2answers
2k views
Allow access to WordPress site only by links in email newsletters
I send out a personal email newsletter, and have been looking into sending it via some service like MailChimp, or sendy.co. Many of these email services suggest, or require, the email newsletter ...
7
votes
2answers
5k views
Can I enable GZIP on Godaddy?
One of my sites lives on GoDaddy's bottom-of-the-line cheap hosting, I have the correct code in my .htaccess file, but it's not compressing because mod_deflate is not loaded.
How do I enable that?
...
7
votes
3answers
4k views
.htaccess permanent redirect to www
I have a WordPress installation that is not redirecting URLs not starting with www.
Example: http://example.com/dir/ doesn't send to http://www.example.com/dir/ instead goes to http://example.com/.
...
7
votes
3answers
40k views
How to remove trailing slashes from URL with .htaccess?
The situation
Across the entire domain, we'd like the URLs to hide file extensions and remove trailing slashes, independent of the domain name itself (as in, works on any domain).
Sample of our ...
7
votes
1answer
7k views
How to set up a 403 forbidden
I've recently set up my first commercial website for someone, with godaddy hosting.
I want to set up a 403 forbidden on several directories (and their contents) that are referenced to through php ...
7
votes
1answer
428 views
home page of my site is not appear in google search, when I type site:example.com
I am totally confused, when I place site:example.com in google I see every page of my website in serp(search engine result page) except the home page. I don’t know why it’s happening but I check ...
7
votes
2answers
5k views
.htaccess redirect url without trailing slashes
In my htaccess I have some rewrited urls like these:
RewriteRule ^first-page$ /subdir/page.php?id_page=1 [QSA,L]
RewriteRule ^second-page$ /subdir/page.php?id_page=2 [QSA,L]
RewriteRule ^third-page$ /...
7
votes
1answer
305 views
Apache rewrite rules for development workstation and server
I've got developers editing pages for several sites on a WAMP stack and then uploading to the public servers running LAMP stacks. We're pretty happy with it, but we have this minor annoyance: we can't ...
7
votes
2answers
1k views
HSTS Preload section on .htaccess
Recently having moved a site to SSL, I looked into enforcing HSTS for eventual preload. The syntax is approved and the Chrome List allows it to be OK. However, not being a coder at all, a slight ...
7
votes
3answers
274 views
How to re-direct Wordpress posts with 301
All my WordPress post URLs generate sub directories with duplicate content and I do not know what regular expression to use to consistently 301 redirect domain.com/category/post/random-number/ to ...
7
votes
1answer
115 views
Restrict access to directories hosting different sites
My hosting provider requires that my primary domain (let's call it example.com) points to my public_html root. I also own several other domains (let's call them exampleA.com and exampleB.com) that are ...
6
votes
6answers
2k views
Removing the dot or period from htaccess files - A dangerous move?
Removing the dot or period from htaccess files (and thus making it unhidden) - A dangerous move?
I tried to search in Google with the string: Can I remove the dot htaccess But I didn't find anything ...
6
votes
3answers
1k views
SSL/https breaking when using www
Please don't close for being a duplicate, I have already tried the other answered questions and am still having issues.
First, I know why the certification for the site breaks when using www. The ...
6
votes
3answers
14k views
Properly force SSL with .htaccess, no double authentication
I am trying to force SSL with .htaccess on a shared host. This means there I only have access to .htaccess and not the main VirtualHost configuration. I know you can put a rule in the VirtualHost ...
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 ...
6
votes
2answers
1k views
How to submit shortened URLs to Google so that they are included in the index
I am working on a project to create a URL shortener. I have successfully gotten it to create short URLs, but I would like to submit them to Google. When I submit a short URL via Google Webmaster ...
6
votes
2answers
91 views
In .htaccess files, is there any difference at all between “!=on” and “off”
I’m trying to better understand Apache’s use of a binary attribute. In an .htaccess file with the code
# Check if HTTPS is 𝗻𝗼𝘁 𝗼𝗻
RewriteCond %{HTTPS} !=on
Is there more processing occurring...
6
votes
2answers
6k views
Have Apache show 404 at missing page URL instead of redirecting to error page URL
Assuming non-existent-page.html does not exist, and the user is trying to access that page and triggered a 404 error.
Can i show the requested page URL:
http://www.example.com/non-existent-page.html
...
6
votes
2answers
3k views
Redirect/rewrite dynamic URL to sub-domain and create DNS for subdomain
I have created an application in PHP, I would like to re-direct the following URL to corresponding sub-domain.
Dynamic URL pattern:
http://mydomain.com/mypage.php?user_name=testuser
I wish to re-...
6
votes
1answer
1k views
How to internally rewrite a page when requested from specific HTTP_HOST
I have a Drupal site, example.com, and our client has a campaign that they're promoting for which they've bought a new domain name, campaign.com. I'd like it so that a request for campaign.com ...
6
votes
2answers
832 views
Is a masked 307 redirect for a domain possible?
I've been asked to create a 307 redirect for a domain, ensuring it is "masked". i.e. keep the original URL in the address bar.
There isn't a lot of info available about 307 (as opposed to 301/302) ...
6
votes
2answers
6k views
htaccess ErrorDocument 500 not working
I have a site whose .htaccess file contains:
ErrorDocument 404 /errors/404.html
ErrorDocument 500 /errors/500.html
The 404 redirect works just fine, but when I encounter a 500 Internal Server Error, ...
6
votes
2answers
1k views
SSL Enforced by Redirect but how to support NON-SNI Browsers
I'd like my website to be SSL only but I'm faced with problem regarding the SSL certification not being supported on older browsers such as IE8, not that I care to much but wondering if there's away ...