Directory-level configuration file found mostly on Apache web servers

learn more… | top users | synonyms (1)

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

How can I use .htaccess to rewrite different domains to different sub-directories, masking the sub-directory?

I have a shared hosting plan that allows unlimited addon domains, but they can only point to the public root (/). I use .htaccess to point different domains to their corresponding sub-directories. For ...
4
votes
1answer
799 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
1answer
25 views

Fastest Redirection on Apache Server with Wordpress for a Small ~200 Page Website

If I have a website of about 200 pages and most of the links will be inevitably changing, what is the faster way to redirect them (fastest not in terms of how quickly I can do it, but in terms of the ...
1
vote
2answers
374 views

301 redirect all pages with a specific extension

I have a website that is not on ASP anymore, it's a Drupal 7 website now. I need to use an .htaccess file to redirect with code 301 all pages with .asp extension to the 404 page or a specific URL. ...
1
vote
2answers
49 views

Creating redirects list from a domain alias to a primary domain

I am trying to set up a list of redirects in my .htaccess to create a manually defined 'short url' list, whereby the short url domain ("short.com") is set up as an alias for the destination domain ...
1
vote
2answers
154 views

How can I rewrite a subdomain to go to a specific file in a specific folder?

I've done searching for my answer and have tested a few solutions, but nothing has worked so far. I'm trying to get a URL like this http://baseball.sports.com to rewrite to ...
1
vote
1answer
58 views

When a mod_rewrite redirect is in place, do absent <img>s still cost more server time than present <img>s?

I have a series of webpages in which the <html> refers to: <img src="img1.png" [...] /> <img src="img2.png" [...] /> <img src="img3.png" [...] /> After I realised that ...
1
vote
1answer
578 views

How to configure mod_bwlimited through htaccess

The mod_bwlimited module in htaccess apparently displays an error if bandwidth is exceeded. Anyone know what options are available for configuring it through htaccess?
1
vote
2answers
181 views

Google still has record of my old site URL - what to do?

I had a blog site, i.e. http://example2.com, then I bought a new domain, i.e. http://example.com and 301 permanent redirected example2.com to example.com. But when I get into the Google Webmaster ...
2
votes
1answer
33 views

Prevent my hosting server from adding a JavaScript snippet to my page?

My host adds JavaScript in particular cases. I want to prevent that. Maybe through .htaccess? The added code is the following So, even preventing their PHP from executing would be useful.
1
vote
2answers
382 views

RewriteRule /change-email.htm?e=someone@somewhere.com&h=xxxxxx

I need to rewrite URL's of this form: /change-email.htm?e=someone@somewhere.com&h=xxxxxx to: /change-email/?e=someone@somewhere.com&h=xxxxx I've done this in my .htaccess: RewriteCond ...
1
vote
1answer
105 views

Can .htaccess be used to cache AdSense JavaScript to improve the pagespeed score?

I'm AdSense publisher and I need to improve the page speed score for my site. It already gets 90/100 for speed and 100/100 for User Experience, however Google AdSense code is preventing it from ...
2
votes
1answer
126 views

Avoid 301 redirect in cdn.domain.mx

I have a domain with a .htaccess redirection problem. The active CDN the URL should be: cdn.domain.mx/images/test.png but redirects: cdn.domain.mx/images/something.png -> ...
0
votes
2answers
39 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 ...
1
vote
1answer
22 views

Using htaccess to internally and externally redirect a page at the same time [duplicate]

I've been trying to figure this out for two hours, and I give up. I want to externally redirect about.php to about/, and also have about/ internally redirect to about.php RewriteRule ^about/$ ...
1
vote
0answers
94 views

Can Apache .htaccess convert the percent-encoding in encoded URIs from Win-1252 to UTF-8?

I want to add a directive in my .htaccess, such that if the browser is pointed at a URI containing %E4 (ä) - or any other special character - the .htaccess automatically rewrites %E4 (ä) as %C3%A4 ...
2
votes
2answers
60 views

.htaccess RedirectMatch not working when *some* users include “www.” in URL

I have recently moved a site to a new domain, and at the old domain, I created a .htaccess file that includes one line of code: RedirectMatch 301 ^/(.*) http://newdomain.com/$1 The goal, of course, ...
1
vote
1answer
27 views

How can I pass optional URL parameters through my rewrite rule?

I created a CMS that identifies if the GET value of url is defined, and if it is, it returns the html contents of the page from the frontend template on index.php. This ideally is to make a templating ...
1
vote
1answer
31 views

Removing “product.php” in URL using .htaccess

The current URL: http://www.example.com/product.php/sample-product.html. I want change it to: http://www.example.com/sample-product.html
3
votes
9answers
10k 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
2answers
2k views

Remove .php and id from URL and replace with slash

I have tried lots of URL rewrite rules in .htaccess but I am stuck now. I have to change this URL: products.php?id=31 to products/31 I have used: Options +FollowSymLinks -MultiViews ...
3
votes
2answers
247 views

Site migration using new and old subdomains and SEO impact

I'd greatly appreciate a response on the following question relating to site migration and SEO impact. Here's some background on how my domain name and site is currently configured: My domain name ...
2
votes
1answer
36 views

Links on Google result list with unnecessary parameters

I have a website that uses .htaccess to turn the parameterized URLs into a folder pattern based URL For example : www.example.com?lang=de&cat=mycategory becomes www.example.com/de/mycategory ...
1
vote
1answer
53 views

Non existent image files are not being handled by PHP as they should due to ngnix configuration

I am currently building a web application. In order for it to work properly I wrote this rule: location / { if (!-e $request_filename) { expires 168h; add_header Pragma public; ...
1
vote
0answers
87 views

Setup WordPress multi-site installation to handle both subdomain.example.com and www.subdomain.example.com

I have installed a multi-site installation of WordPress onto my domain. I then added the necessary code to the wp-config.php file and .htaccess as instructed by WordPress. I also installed a plugin ...
1
vote
2answers
112 views

Remove trailing slash and index.html in .htaccess

I seem to be stuck here trying to figure out how to redirect the following scenarios: /foo/index.html -> /foo (remove trailing slash, index.html as 301) /foo/ -> /foo (remove ...
1
vote
2answers
33 views

Use .htaccess to configure subdomains serve content from folders rather than from the root domain

Here is site http://www.glassnow.com.au/ With 3 subdomains: brisbane.glassnow.com.au goldcoast.glassnow.com.au sunshinecoast.glassnow.com.au Here is htaccess RewriteEngine On RewriteBase / ...
2
votes
1answer
34 views

Forbid users from accessing a long URL while allowing access to a shorter one with mod_rewrite

I'm trying to block the following URL: www.example.com/Ayurveda/article/guna/alkalizing/contains/non-vegan/experience/relieves-burning But I want to allow: ...
2
votes
2answers
295 views

Error 404 after rewrite query strings with htaccess

I'm trying to redirect the URLs of a client's website like this: www.localsite.com/immobile.php?id_immobile=24 In something like this: www.localsite.com/immobile/24.php I'm using this rule in ...
1
vote
1answer
280 views

Is there a “current directory” variable in .htaccess RewriteRule?

In a .htaccess file in the subfolder "/preview" (not in document root), I have this rule: RewriteRule !^public/ /preview/forbidden.php [L,R] It redirects all /preview/"something" requests that are ...
2
votes
1answer
45 views

WAMP: Properly directing image paths on local server

I'm using ExpressionEngine to build a site, and have a development version running locally via WAMP. Within the root "www" folder, I have an "ee" subdirectory that acts as the root of the development ...
1
vote
2answers
707 views

Htaccess redirect based on country of origin

Can a rule that filters and redirect traffic based on country of origin be implemented in .htaccess? Can it be implemented in any other way then by an IP address? I need the solution to be as ...
1
vote
1answer
288 views

htaccess/cPanel 301 redirects not working for add-on domain

I've already looked at many samples and tutorials how to set up those 301 redirects on Apache and can't figure out why some are not working. Whenever I want to redirect any still existing page from ...
2
votes
1answer
56 views

Apache virtual hosts configuration for MAMP results in new sites going to the same folder

I have MAMP installed in my mac. Why is it that every time I create a new site, they all go to the same folder? Here is my /etc/hosts file: 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 ...
3
votes
1answer
49 views

Can .htaccess 301 redirects work with encoded characters?

I have an old site with titles in the URL for SEO, but it has URL encoded characters than transliterated Latin characters. Like %20 instead of space character and many other non-Latin characters. The ...
3
votes
2answers
147 views

My .htaccess entry is not working

The below are all my .htaccess entry: RewriteEngine on RewriteCond %{HTTP_HOST} !^www\.acethehimalaya\.com$ [NC] RewriteRule (.*) http://www.acethehimalaya.com/$1 [R=301,L] redirect 301 ...
1
vote
0answers
31 views

How can you use Apache .htaccess to specify the location of the PHP binary on shared hosting?

I'm using shared hosting, can create .htaccess and php.ini and have access to ssh. I have PHP 5.6 installed to ~/public_html/php56 and can use this path with ssh, cron and exec() but not on the web. ...
2
votes
1answer
34 views

Redirecting www to non www in subfolder

I have Joomla installed on root folder and another Joomla installed on a subfolder. I want to redirect www to no-www in subfolder by this code in blog .htaccess: RewriteCond %{HTTP_HOST} ...
2
votes
1answer
1k views

Subfolder non-www redirect

Is there a way to redirect a sub folder to no-www? What I use is: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] but this only ...
0
votes
1answer
2k 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 ...
1
vote
1answer
77 views

Permanent redirections after changing the product links structure on Prestashop

I'm looking at changing the products URLs' structure on a Prestashop (v1.5) website. That process is quite straight-forward and it can be done instantly through the corresponding admin panel. The ...
0
votes
1answer
41 views

RewriteRule not working properly in my Ubuntu server 14.04 running in Windows Azure

In my server I kept signup.php and in .htaccess I kept this thing - RewriteRule ^/registration/?$ http://www.example.com/signup$1 [R] But this is not redirecting www.example.com/registration/ to ...
0
votes
1answer
100 views

Showing content from pages at different URL's (masking), possibly with .htaccess

If I have URL's like:- domain.com/category/widgets/filter/blue domain.com/category/widgets/filter/red And it is pretty difficult to reconstruct them to something like:- ...
1
vote
0answers
60 views

ExpiresByType not working for PNG images when set in .htaccess for a WordPress site

In my website I have the expires headers settings reported below. When I use Google's PageSpeed Insights test I get the message: XYZ.png expire headers not set, which I'm getting for all the PNG files ...
1
vote
1answer
317 views

Rewrite rule for 403

I have an .htaccess file: In this file it redirects to index.php in case a file or directory is not found. My code is as below: <IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} ...
2
votes
2answers
66 views

Duplicate content error results instead of a 404 page

My current URL is: www.example.com/category/we-developer/ However, if any user mistakenly adds extra characters after the /, for example, www.example.com/category/we-developer/fgggfgg, it should take ...
4
votes
2answers
3k views

How to write a generic .htaccess file rule, regarding RewriteBase

The following rule in my .htaccess works just fine for routing calls to index.php: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php [QSA,L] However, this does not ...
1
vote
2answers
56 views

How to display “Not Found” instead of automatic redirecting?

how to redirect to 404 in .htaccess file ? Example www.domain.com/ja/any_post or www.domain.com/ja/all_posts www.domain.com/fr/any_post or www.domain.com/fr/all_posts A little bit more ...
1
vote
1answer
42 views

htaccess RewriteRule: Premature ending of rewrite iteration?

I'm still trying to grasp the concept of Apache's RewriteRule, so please confirm if my understanding of the below is correct... So, here's a snippet of a website's .htaccess, I add numbers in front ...