Questions tagged [.htaccess]

20792 questions
1

votes
0

answer
140

Views

Configure Apache as a Reverse Proxy To Point Tomcat On GoDaddy VPS

I need to setup reverse proxy on godaddy vps (Cent OS, Apache 2.4) to transfer request from Apache port 80 to my Java application running on tomcat 7. I have come across a various answers but nothing works. Even on godaddy site they provide some way to configure the reverse proxy but its not work. P...
itnt system
1

votes
2

answer
292

Views

.htaccess add Custom Header to File directive matching pattern

I have on my website many pdf's that ends with a digit although they are the same pdf. I want to add a Canonical Link via .htaccess (using Files or FilesMatch) to the pdf's that ends with a digit to the corresponding pdf I think the pattern needs to be {anything}-{digit}.pdf Ex: Header add Link '; r...
AdrianD
1

votes
0

answer
32

Views

how to set dynamic domains and subdomains in /etc/hosts

in /etc/hosts file 127.0.0.1 admin.localhost 127.0.0.1 school1.admin.localhost 127.0.0.1 school2.admin.localhost 127.0.0.1 school3.admin.localhost 127.0.0.1 school4.admin.localhost 127.0.0.1 school5.admin.localhost I want to replace school1-school2 with a text so that it will support...
1

votes
1

answer
53

Views

Htaccess Redirect a folder and exclude two subfolders

I can't figure our RewriteRule so I've tried RedirectMatch. I need to match to a folder /2018/ and all other sub-folders but I do not want to redirect /2018/speakers/ or /2018/events/ RedirectMatch 301 ^/2018/$^(speakers|events)($|/) https://example.com/north-america Doesn't seem to work and I reall...
Spencer Padway
1

votes
0

answer
108

Views

Nginx keeps redirecting on a base install of laravel forge

Although I do not have laravel setup on the server I am just trying to display some php files In my root directory I have /public/dashboard which is executed by domain.com/dashboard It shows up fine but as soon as I try to append something to 'dashboard' it redirects back to /dashboard For example...
Chad Priddle
1

votes
0

answer
87

Views

htpasswd protected folder with json file in returning 401 when fetching json

I have a folder in a directory (/cars) which I have password protected using a .htaccess and .htpasswd file. For simplicity's sake I have two files in this folder: index.php and carsData.json. Within index.php I have some javascript which calls the carsData.json. However I get the following error in...
user3725781
1

votes
1

answer
51

Views

change permalink through .htaccess

i want to change my permalink example www.testing.com/1234/'titlename' instead of www.testing.com/1234/, how to do i change it through .htaccess? Below are my .htaccess code RewriteEngine on RewriteBase /clients/ohmynews/web/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Re...
Mun Kiat
1

votes
0

answer
195

Views

codeIgniter 3 redirect host domain to index [duplicate]

This question already has an answer here: Set up the base url in codeigniter 3 answers CodeIgniter removing index.php from url 29 answers I am trying to redirect my domain.com to domain.com/index. I tried both via route.php and httaccess. but not working. route.php $route[''] = 'front_controllers/...
1

votes
1

answer
31

Views

Removed .php file extension using htaccess but now my php code is no longer working?

I am trying to remove the .php file extension for a page hosted online. I managed to remove the .php file from my URL however some of my php code within my page is no longer working... the php code is now appearing on the page as iof not compiled... the page is called blog.php my .htaccess is as fol...
Grem357
1

votes
1

answer
19

Views

Adding trailing slash - Specific rules

I've got this setup: RewriteRule ^brands$ brands/ [R=301,L] RewriteRule ^brands/$ /brands.php RewriteRule ^brands/([A-ZÆØÅæøåa-z0-9-]+)-([0-9]+)/$ index.php?manufacturers_name=$1&manufacturers_id=$2 [L,QSA] RewriteRule ^brands/([0-9]+)$ index.php?manufacturers_id=$1 [L] How would I fix it so t...
Dennis A
1

votes
1

answer
27

Views

Redirect user to the secure connection when hit the domain

I have written a rule in .htaccess it was working great according to the requirement now there is a slight change in the requirement and I am confuse that how can I accomplish that by changing my previous rule the first rule which is working is that when when ever user hit the domain example.com or...
Mohsin Abbas
1

votes
1

answer
43

Views

nginx and htaccess rewrite rule with optional parameters

I'm trying to make a rewrite rule in NGINX and .htaccess. Now, I have a link http://project2.local/recordings which can be accessed like that, but it has an optional parameter camera. So you can access the link also like this: http://project2.local/recordings/camera/1, now it also has another option...
Robin
1

votes
1

answer
84

Views

Rewrite everything exclude index.html

I've got following structure of site: index.html /assets/subpage.html /assets/secondpage.html And I wrote following rules in .htaccess: RewriteRule ^([^\.]+)$ $1.html [NC,L] RewriteEngine On RewriteCond %{REQUEST_URI} !^/assets RewriteRule (.*) /assets/$1 [QSA,L] I want to delete .html from files (...
David
1

votes
0

answer
28

Views

.htaccess: Block all files but images and stylesheets?

I need to block access to all files on my website except for images and my stylesheet. I need to do this in an .htaccess file. How can I manage to do this? My current .htaccess-file looks like this: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule '^([^/]+)/([^/]+)/([^/]+)' index.php...
1

votes
1

answer
43

Views

Redirecting Domain to Subfolder

Currently I have this on my htaccess RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ RewriteCond %{REQUEST_URI} !^/real-estate [NC] RewriteRule ^(.*)$ /real-estate/$1 [L] I want to redirect the user mydomain.com -> mydomain.com/real-estate www.mydomain.com - > www.mydomain.com/real...
SKS
1

votes
1

answer
42

Views

Remove .php extension / .htaccess / Apache2.conf - What should be modified to make it work? [duplicate]

This question already has an answer here: Remove .php extension with .htaccess 13 answers I would like to remove the .php extension from my website. I have this structure: /var/www/site/ FYI, in folder site, I have a lot of subfolders. In site folder, I create .htaccess file. I inputed these line...
Steph
1

votes
1

answer
25

Views

Redirect from “/foo/bar/…” to just “/…” via .htaccess file

I had all my website at example.com/foo/bar/. I now moved it to just example.com/, to improve readibility. How can I redirect via a .htaccess file all visitors that still go to example.com/foo/bar to example.com/? I need all subdirectories to be redirectd too: for example from /foo/bar/baz to /baz,...
Jack
1

votes
0

answer
179

Views

iframe screenshot on cross domain

I have an iframe loading a flash game embedded on domain1.com. The iframe is originating from domain3.com and domain3.com has the following CORS code in the htaccess file to allow access to domain1.com and additional domains. SetEnvIf Origin 'http(s)?://(www\.)? (domain1.com|domain2.com)$' AccessCon...
Alangoodie
1

votes
1

answer
502

Views

Prevent download of an mp3 in wordpress but let it be played via WP-Plugin

I'm uploading some self composed music to my website which shall be played with an Audio-Plugin. I stumbled over the opportunity to catch the direct links from the HTML source code. Now i tried to protect the files with an htaccess file in that Folder (i found that solution in another Forum) Options...
Söby
1

votes
1

answer
75

Views

Wordpress Permalinks Overriding .htaccess https and force slash

I am wanting to use the following .htaccess however it works to a point but for me to access the sub pages I have to reset my permalinks and there for this section gets reset. It seems in Wordpress currently there is only plugins to do one or another - not both of my goals. Goals: To force HTTP:// t...
Jess McKenzie
1

votes
1

answer
125

Views

Redirecting to backend via htaccess Yii2

I am trying to redirect my url to the admin ( backend ) part on domain/admin via htaccess. Still not very familiar with .htaccess and what I did so far is Main .htaccess in the root directory: #adding the charset AddDefaultCharset utf-8 #hide the structure Options -Indexes #if dir is symbol, follow...
Toma Tomov
1

votes
0

answer
200

Views

.htaccess not working on my webserver (404 - not found) how to fix?

My .htaccess file: RewriteEngine on # Rewrite /foo/bar to /foo/bar.php RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L] # NOTE! FOR APACHE ON WINDOWS: Add [NC] to RewriteCond like this: # RewriteCond %{THE_REQUEST} '^[^ ]* .*?\.php[? ].*$' [NC] The .htaccess simply removes the PHP extension, http://myw...
dizzy
1

votes
1

answer
26

Views

How to direct a Domain to a subfolder on the server it points to in apache htaccess

I have a web server with several Domains pointing to it. I want one domain lets name it www.example.com to go into the folder /example in my Doc Root (e.g. /var/www/example). I do this using this .htaccess code in my Doc Root: RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^(www.)?example.c...
ulanBator
1

votes
0

answer
18

Views

.htaccess Mod Rewrite Issue

I have following rewrite rule in htaccess and its not working for first part for EventList.php. Will appreciate some help to figure out whats wrong. I am adding this in a wordpress website htaccess file. RewriteEngine On RewriteRule ^Local-Event/([0-9]*)$ /Eventbrite.php?page=$1 [QSA] Re...
Sam Seth
1

votes
0

answer
114

Views

Is a possible way with .htaccess to fix HPKP?

Deciding to set up the HTTP Public Key Pinning Process i have tried some codes with my .htaccess it looks like that : Options +FollowSymLinks -MultiViews RewriteEngine On RewriteCond %{HTTP_HOST} ^website.com RewriteRule (.*) https://www.website.com/$1 [R=301,L] Header edit Set-Cookie ^(.*)$ $1...
Robin
1

votes
1

answer
130

Views

How to add headers to assets for cache validation?

I've been googling and testing stuff for the past couple of days but unfortunately I cant find a solution for my problem... I am working on a Symfony 2 application that uses a Service-Worker to cache a bunch of assets. For whatever reason I can't seem to add headers like ETag or Expires to the asset...
Richard Avalos
1

votes
1

answer
284

Views

Refresh or Direct Url not working after bundle with webpack in react js?

I had an issue that the react js app with browser history only working on normal. But after build with webpack, i had an issue with refresh or paste relative url. If i'm using hash history instead of browser history it works well. I used several methods, but i'm only getting the issue Mostly says...
1

votes
0

answer
78

Views

NGINX rewrite to public with /

Tried the search but didn't found a solution yet. I am trying to get the next url working a nice urls.. URL.com/public/index.php?url=admin/loginform to URL.com/admin/loginform I tried to set the root folder and a location ~^ /public/ directive but can't get it to work. location / { root /srv/URL.com...
Pjelp
1

votes
0

answer
93

Views

Mod Pagespeed is applied partially. Combining only few JS files and rest are not combined

I have mod_pagespeed installed for apache and for 1 website I have enabled it using .htaccess. Below is the .htaccess code : ModPagespeed on ModPagespeedEnableFilters combine_javascript ModPagespeedEnableFilters collapse_whitespace,elide_attributes Though combine JS is written. It doesn't combine al...
Vivek Tankaria
1

votes
0

answer
10

Views

.htaccess regex file

I would like some help regarding regex in .htaccess for url. I have this url I want to represent, I am pretty sure my regex code is accurate but when I load the page it gives me a 404 error. I am not sure but maybe I am missing something. Please help me out if you can. original: display-item.php?ic=...
Wangara Margai
1

votes
1

answer
339

Views

Wordpress custom post type permalink rewrite posts issue

I have just managed to rewrite the URL permalink structure for my custom post types which is working just the way I want, however since adding these rewrites my blog posts have started going to a 404 page. in my functions.php file I have: 'rewrite' => array( 'slug' => '%companies%/projects', 'with_f...
Duggy G
1

votes
0

answer
291

Views

Removed Content-Security-Policy(CSP) header from .htaccess still resources are blocked

I am very new to Content-Security-Policy. I added this header in .htaccess file my website to add security but it has broken my website. I tried to white list all the domain with the related resources but that didn't work. Now I want to completely remove this header from my website. I tried followin...
Ashuosh Bajpay
1

votes
1

answer
20

Views

htaccess redirect some partical url 301 SEO

something on our BLOG URLS have changed. No i want to have some URL path deleted in urls. Example: OLD URL: https://do-main.de/blog/entry/die-xxx-der-portrait NEW URL: https://do-main.de/blog/die-xxx-der-portrait My htaccess attempt to setup: #OLD BLOG URLS RewriteEngine On # anything that is...
Alorsons
1

votes
1

answer
257

Views

Wordpress SSL & www rewrites

Having an issue with some url rewrites. I want to redirect all urls to https with no www Currently I have : 1) Forces https with the (s) - working http://example.com => https://example.com 2) Forces https with the (s) and removes www - working http://www.example.com => https://example.com 3) R...
user892670
1

votes
1

answer
111

Views

Archive navigation on Wordpress - Solution with .htaccess redirection

I have a problem with the navigation of my category archive (Wordpress). My website structure is example.com/blabla-news/post-name/. When I go into my category archive and want to click on page 2, it's showing me a 404 Error page i.e example.com/blabla-news/page/2 is a 404 Error page. I've found th...
Harold Martinez
1

votes
1

answer
48

Views

Excluding a Directory from Redirect - Wordpress

Crrently I am having a problem with redirection. The problem is that I want to redirect all further category paths to 1 category. Example: example.com/news-blog/post-name/ and need to redirect to example.com/news/post-name/ I've successfully finished that with the following code: RewriteRule ^news-...
Harold Martinez
1

votes
1

answer
802

Views

Debugging Apache AllowMethods error

We are running an API for our mobile app, and with the right HTTP headers, have been able to enable developing it locally using the live API without the need of a 'CORS plugin'. Now, it does not work anymore, probably since moving the domain name from one user to another (using DirectAdmin), but I...
Sygmoral
194

votes
29

answer
166.5k

Views

Laravel 5 – Remove Public from URL

I know this is a very popular question but I haven't been able to find a working solution for Laravel 5. I've been trying to migrate from Codeigniter for a long time, but this convoluted installation process keeps putting me off. I don't want to run a VM, this just seems awkward when switching betwe...
user1537360
1

votes
0

answer
37

Views

Htaccess redirect to page and change the url

I want to redirect to www.domain.com/store/bg/user/login but to rename the url to www.domain.com/storeadmin/bg/user/login without affect the rendered view. What I am doing to redirect ot the login page on this kind of url www.domain.com/storeadmin is: RewriteCond %{REQUEST_URI} ^/?storeadmin/([a-z]{...
Toma Tomov
1

votes
0

answer
79

Views

Mod_rewrite (.htaccess) causing 500 server error when removing extensions (.html) from URL

I was looking for a solution on many topics (E.g. 1, 2, 3, 4, 5, 6, 7,8). Unfortunately, I did not find a good solution. Overall, I want to achieve the following effect: no www. at the beginning of the URL, no .html or / at end of the URL, URL containing the full path to the file (but without showin...
Maciej Rzepinski

View additional questions