Directory-level configuration file found mostly on Apache web servers

learn more… | top users | synonyms (1)

4
votes
1answer
1k 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 ...
2
votes
2answers
234 views

How to set restrictions on my website?

Currently my website is under maintenance. I want to be the only person who's able to access/view the website online until I finish maintenance. How to set restrictions to others ? I hate stalkers.
5
votes
3answers
23k 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 ...
6
votes
3answers
2k 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/. ...
4
votes
2answers
4k views

.htaccess directory to subdomain

I have been trying to make a subdomain from a directory (made by .htaccess) to be used as the main page starting like http://domain.com/sub/2/3/4.html and turning into ...
3
votes
3answers
3k views

Subfolder won't permenantly redirect to subdomain

Right now I have the following code to redirect all non-www URLs to www URLs: RewriteCond %{HTTP_HOST} ^example.com RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] Besides that redirection, ...
0
votes
4answers
166 views

Redirect everything from old domain to new domain

I need to (permanent) redirect all of the following: www.domain.com www.domain.com/folder sub.domain.com sub.domain.com/folder Basically all URLS that are reachable without being intended to: ...
14
votes
4answers
564 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 ...
3
votes
1answer
258 views

Redirect www to non-www using Apache htaccess does not work

I have this in my .htaccess (modified from the default Drupal .htaccess): RewriteCond %{HTTP_HOST} ^www\.website.com\.com$ [NC] RewriteRule ^(.*)$ http://website.com/$1 [L,R=301] In theory this ...
11
votes
2answers
2k 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 ...
10
votes
1answer
341 views

301 redirects for all except me

i want to my site down for an hour and i was using order Deny,Allow Deny from all Allow from my.ip.add.ress but i dont like the default error page, is there a 301 redirct where i can redirect ...
5
votes
1answer
2k views

Redirect from SSL HTTPS to HTTP (NO SSL)

Many of my visitors have bookmarked my site already with https://mydomain.com. Under the bad advice of a programmer I have put my whole site (Joomla) using SSL. I do not sell anything or provide any ...
4
votes
2answers
539 views

Trigger IP ban based on request of given file?

I run a website where "x.php" was known to have vulnerabilities. The vulnerability has been fixed and I don't have "x.php" on my site anymore. As such with major public vulnerabilities, it seems ...
3
votes
1answer
2k views

Clean URLs without PHP file extension

I want to make my URLs clean, for example: http://sample.com/about-me instead of: http://sample.com/about-me.php This is my code: RewriteEngine On RewriteBase / RewriteCond ...
3
votes
1answer
146 views

.htaccess Redirect Old Threads

I have moved to mybb to vanilla and want to redirect old threads to the new format, so the indexed threads on google aren't lost. The old format is showthread.php?tid=3003 Whereas the new ...
3
votes
2answers
3k views

Use .htaccess to rewrite requests for a PNG as a PHP GET variable

I'm REALLY bad with .htaccess files, and reading through the existing questions on SO only confuse me more (mainly because they're all situation-specific and don't exactly apply to my situation at ...
0
votes
1answer
183 views

Stop searches showing tld domain sites appearing as subdirectory of main holding site domain?

I'm not sure if this is a problem specific to how my hosting is structured or not. Let's say the main domain for my account is maindomain.com (for purpose of discussion) I am building other sites, ...
8
votes
3answers
3k 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: ...
2
votes
2answers
9k views

Redirect/Rewrite Subdomain to Subfolder

I'm trying to redirect a subdomain to a subfolder e.g. forums.domain.com to www.domain.com/forums Note that I started the forums in the subfolder format but worried that members might mistakenly try ...
1
vote
4answers
149 views

Using a .htaccess to RewriteRule and Redirect 301 at the same time?

I have a couple of specific URLs that I want to display differently on my website, like this: RewriteRule ^contact$ contact.php To get ride of the ".php" extension. And to be SEO friendly (to ...
1
vote
2answers
3k views

.htaccess and browser caching

I ran across these suggested htaccess edits. Is this a good practice? Is this something I should implement on my wordpress site?: <IfModule mod_expires.c> ExpiresActive On ExpiresByType ...
1
vote
1answer
99 views

I need a little help with .htaccess rewrite

I need a little help with .htaccess file I have songs, singers and albums links I want to rewrite. I all ready rewrote the links and they are like this: the links for the songs is like this: ...
13
votes
4answers
637 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 ...
5
votes
1answer
104 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 ...
3
votes
9answers
12k 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 ...
1
vote
1answer
660 views

htaccess and 301 redirects - multiple domains

I have the following which redirects mydomain1.co.uk and mydomain1.com to www.mydomain1.com perfectly. RewriteCond %{HTTP_HOST} !^(.*)\.mydomain1\.com$ [NC] RewriteRule ^(.*)$ ...
6
votes
5answers
8k 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 ...
7
votes
2answers
215 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 ...
5
votes
1answer
910 views

How do I setup authentication on a specific folder using .htaccess?

I have a folder that I want to host files privately on my webserver. How do I go about making it password protected using .htaccess? Note: Nothing monolithic, I want something that is simple/easy so ...
4
votes
6answers
636 views

SEO - which URL's are the best?

I'm using .htaccess with RewriteRule to create SEO-friendly URL's. However, I have a few questions about this: First of all, I noticed many websites end their URL's with .html (or another ...
4
votes
4answers
265 views

How to restrict access to my site using htaccess

How to disallow access to site except me?
3
votes
1answer
14k views

How to redirect any URL to lowercase URL?

I have this .htaccess files: ErrorDocument 404 /index.html <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^domain\.com [NC] RewriteRule (.*) ...
1
vote
2answers
40 views

Hiding and redirecting extensions on my webpage

I want to hide extensions on my webpage using the .htaccess file. I have managed to do it by using this code; RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php ...
1
vote
2answers
2k views

.htaccess redirect to subfolder in different domain, maintaining old domain in the URL

Redirect has been widely discussed and most problems solved, so I am sorry for opening yet another post about this, but none of the codes I am trying work. I have a WordPress site hosted in ...
0
votes
2answers
398 views

htaccess and htpasswd trouble

This is the first time that I have ever tried working with .htpasswd and .htaccess files, so please point out my childish works. I have my apache document root set to /www/ on my debian server. ...
0
votes
1answer
158 views

Switch to https

I'm looking to use an .htaccess file to use mod_rewrite to switch the protocol from http:// to https:// when someone hits my website. For instance, once someone goes to: http://www.mywebsite.com/ ...
7
votes
1answer
331 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 ...
6
votes
1answer
3k views

.htaccess rule to redirect from 404 to search results

When a user (or a bot) request on non existing page, I want to redirect him to the search results. I prefere to do it with the .htaccess file using something like: ErrorDocument 404 ...
5
votes
1answer
753 views

How can redirect pages from old core PHP site to new Joomla site?

We have our old site into core PHP and we have developed it again into Joomla 1.5 last year (because of some limitations we have to build it into 1.5). Now the problem is the URL of sites changed as ...
4
votes
1answer
156 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 ...
4
votes
1answer
2k 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? ...
3
votes
1answer
449 views

Removing file extensions off the url

I am looking for a way to remove the extensions off the end of the Url. So say for example www.example.com/about.html. This would change to www.example.com/about I've looked around and searched for ...
3
votes
1answer
1k views

Will adding “www.” to my domain setting in Google Analytics impact already collected data?

I have a profile in Google Analytics (GA) that has been collecting data for a year. The domain setting in GA is "http://example.com". The site, however, will redirect any non-www request, to ...
3
votes
1answer
55 views

How to have my customized extension?

I have recently found a .htaccess trick in which I can remove file extension from the URL, example.com/file.html looks like example.com/file Now my humor says that I can replace any extension to my ...
3
votes
3answers
1k views

Joomla 1.5 to Wordpress 3.1 migration: how to redirect Joomla's permalinks

I'm migrating a Joomla 1.5 site to a WordPress 3.1 site (I will later update to WP 3.2.x) and I've found the right tool to do it, a plugin called Joomla 1.5 Importer. There is another plugin called ...
3
votes
2answers
434 views

RewriteRule not working for certain URLs

There are a few domains pointing towards the same server, and of course I need them all redirect to only one of them. Redirects work, but only for certain URLs. What works: http://www.domain.com, ...
2
votes
2answers
166 views

How do I use a htaccess redirect to force www and use the .org domain while maintaining the URL path?

I have found this rule that does about 90% of what I want, but not quite everything. My main goals for the redirect are to 1) force www. 2) redirect .com to .org. This does that, but if I were at ...
2
votes
1answer
75 views

How to remove php extension from pages except search results?

Using htaccess I have these php rules: <IfModule mod_rewrite.c> Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / ## don't touch /forum URIs RewriteRule ...
2
votes
2answers
60 views

Getting 301 redirect error in Google Webmaster Tools while using “change address”

So I'm moving my website from one domain to another. In this process I'm using the "change address" function in Google Webmaster Tools on my old-domain.com, "switching" it to / choosing my verified ...
2
votes
2answers
129 views

404 not found errors when using Modx CMS in a subfolder

I have installed Modx CMS on my hosting provider, but instead of installing it on my root directory where it usually goes, I put it in a folder on the root directory called makeabio. directory loads ...