Questions tagged [.htaccess]

12072 questions
0

votes
0

answer
5

Views

Wordpress post preview link redirecting on home page. I want to stop it

I have laravel website and there is blog folder which contain wordpress blog. In my htaccess I want some path that allow to open otherwise redirect on home. So my post preview link also redirect on home page. I want to stop it. Preview link is like https://www.test.com/?p=16286. I want to redirect...
P.patel
0

votes
0

answer
3

Views

301 Redirect in .htaccess is appending old file path/name to new url

I have two URLs: old-site.com and new-site.com. My root folder on the old-site.com has NO FILES in it but only the .htaccess file. I don’t want to use the old domain anymore. However, I do want to pass the link juice to the new domain. Therefore, I created 301 Redirects in the .htaccess file and...
Free Stylah
1

votes
1

answer
1.2k

Views

Error for customize page error 500

I dont know why i cant customize error 500 but its good for 404, 403 I have folder like that www index.php .htaccess (2) error index.php .htaccess (1) the first htaccess RewriteEngine on RewriteBase / # Error ErrorDocument 403 /error/index.php?error=403 ErrorDocument 404 /error/index.php?error=404 E...
Mozinor
12

votes
3

answer
105

Views

Repercussions of redirecting root domain to subdomains

Let's say we have a domain for example www.example.com And we have some subdomains for different countries au.example.com us.example.com uk.example.com eu.example.com What are the disadvantages to this. I'm speaking from an SEO Google perspective and anything else you may think of? The problem We ha...
Jordan Quartermain
0

votes
0

answer
3

Views

ErrorDocument 404 parent directory

I am trying to set a custom error page in htaccess (locally on EasyPHP DevServer). I found that code but it only works if I define the project's directory (e.g. /myproject/index.php). # Does not work ErrorDocument 404 /index.php # This works ErrorDocument 404 /project/index.php I tried to search for...
CrazY D
1

votes
1

answer
2.9k

Views

deflate svg files with mod_deflate

i have the mod_deflate for apache enable but it doesn't works on svg files... how can I enable it? or at least allow the svgz extension on prestashop so that I can upload it directly compressed. Thank you # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside thi...
Marwane
0

votes
2

answer
18

Views

htaccess Canonical URL and HTTP->HTTPS redirects (custom url)

I hope so you could help me solve this issue. I am trying to setup my apache server redirects, but without success. I am trying to do this at at once: http://www.example.com -> redirects to -> https:/ /example.com http://example.com -> redirect to -> https:/ /example.com https://www.example.com -> r...
Jordan Lipchev
0

votes
0

answer
9

Views

htaccess DirectoryIndex multiple file names

Quick question, is it possible to set the DirectoryIndex in an htaccess to just look for a specific file type vs a specific file name? I'd like to have the following as the default load page, without creating an index file within the folders /folder/asdasdhsajdh.html /folder2/dusiuiosfu.html I'm goi...
Scott Hamilton
1

votes
2

answer
188

Views

Redirect a 404 to another page and capturing the page with .htaccess

Alright, what I'm wanting to do is create a .htaccess that will redirect any 404 error to another page while capturing the path/file attempted to be accessed. So, if they are trying to access www.mydomain.com/xxx I want it to be redirected to www.mydomain.com/error.php?e=xxx. I've never been ove...
Kevin Lupo
1

votes
2

answer
48

Views

redirect all wild card subdomains and subdomain urls to the root domain and root domain urls using htaccess

Im bit stuck here . Im trying to redirect my subdmain in this manner. anysubdomain.my_domain.com and its urls must redirected to root domain and its urls respectively. for example if a user tries (1) http://anysubdomain.my_domain.com it should redirect to https://www.my_domain.com and (2) if...
user879
1

votes
1

answer
1.7k

Views

Blocking specific extensions in htaccess

I have a directory with files like: /files/archive.01.json /files/archive.02.json /files/archive.03.json /files/hello.php I need the .htaccess to block access to all .json files in that directory. Any ideas?
Andres SK
1

votes
3

answer
9.9k

Views

CodeIgniter URL not found

enter code hereI got this code in my .htaccess file: RewriteEngine On RewriteBase /projFolder ### Canonicalize codeigniter URLs # If your default controller is something other than # 'welcome' you should probably change this RewriteRule ^(mycontrol(/index)?|index(\.php)?)/?$ / [L,R=301] RewriteRule...
Lachezar Raychev
0

votes
0

answer
5

Views

How to log access and error in php using htaccess?

Is there any way, how to log access (and php errors) to my web server using htaccess ? I want to log these information into some log file. I can make logger on PHP script level, but I think its not best way how to log app. I have a rented web server and the only htaccess is available
mawocuy
0

votes
2

answer
16

Views

Show HTML content wit PHP (and load style)

I have some HTML pages (in 'web' folder) that use some styles and scripts, and i need to show these HTML pages using a PHP script. Here is a simplified version of the code i'm using:
Badr
1

votes
0

answer
33

Views

session override in .htaccess, and even php ini_set not working

UPDATE I have been unable to change the session lifetime - I am logged out my session very quickly - not long enough... I have made a php.ini file and set the session.gc_maxlifetime to 3 seconds I have tried with code, to over ride session.gc_maxlifetime - one method being ini_set('session.gc_maxlif...
George Richardson
1

votes
0

answer
3

Views

.htaccess Rewrite Rule does not work correctly with index.php?path

Hi I have the following old url www.domain.de/index.php?leistungen and the new one is www.domain.de/leistungen I tried the following RewriteRuile like I did it millions of times. RewriteRule ^index.php?leistungen /leistungen/ [L,R=301] But in this case I got the following result: www.domain.de/path...
Felix
1

votes
2

answer
328

Views

Simple .htaccess rewrite rule returning 'Not Found' issue

I have this code: Options -Indexes Options +FollowSymlinks RewriteEngine on RewriteRule ^referral/([0-9]+)/?$ /referral.php?code=$1 [NC,L] It is supposed to do two things: block the access to folders' content modifies a URL that ends with referral/[email protected] to [email protected]
Maleka
1

votes
0

answer
22

Views

PHP session subdomain + script

I have a webpage with a subdomain, and I want to share the PHP session with the subdomain. I thought this was already done by setting the .htaccess of the main domain to: php_value session.cookie_domain '.example.com' php_value session.save_path /tmp Header set Origin 'https://sub.example.com' Heade...
1

votes
0

answer
8

Views

htaccess is not working after upload to apache server

I finished a website and on my pc it runs perfectly fine with xampp, but from the point when I upload the project to a webspace from 1und1.de the .htaccess file is not working anymore and I get a 500 Internal Server Error. I am not completely into .htaccess files but I needed a file, that redirects...
Janik F
1

votes
1

answer
142

Views

Codeigniter htaccess not working in ubuntu 16.04

This application biuld in Codeigniter Version = 3.1.3. when build this application work it properly with this htaccess file but today when i run this application & face this type of error. When run my codeigniter website, htaccess file can't rewrite my index.php url. so, requested URL was not found...
1

votes
1

answer
37

Views

.htaccess redirect to subdirectory if no 'www.' in requested URL

I'd like to keep users at the main directory of my domain if they enter the domainname as www.mydomain.de , but redirect them to a subdirectory if the domain is entered without the 'www.'. I know it makes little sense, but I desparately need it for temporary testing purposes while preparing a websit...
richey
1

votes
1

answer
28

Views

.htaccess Rewrite Rule to keep exception for folders

I used this code RewriteRule ^/([^\.]+)$ profile.php?u=$1 [QSA,L] It worked fine for me but when i tried to visit a file in next folder like http://example.com/blog it automatically shows the profile.php code. Is there any method to skip folders during that htaccess? PS: In username Alphanumeric ch...
Aadarsha
1

votes
2

answer
303

Views

.htaccess url rewrite existing directory

I've got a problem concerning my .htaccess I use the following Rewrite Rules: RewriteRule ^/?([\w]+)$ /index.php?$1 RewriteRule ^/?([\w]+)/?([\w]+)$ /index.php?$1=$2 RewriteRule ^/?([\w]+)/?([\w]+)/?([\w]+)$ /index.php?$1=$2&$3 RewriteRule ^/?([\w]+)/?([\w]+)/?([\w]+)/?([\w]+)$ /index.php?$1=$2&$3=$...
Daniel Wohlgemuth
1

votes
1

answer
20

Views

2 Rewrite Rules in .htaccess?

First of all, i have this rule already to redirect non www to www. on the site: Options +FollowSymLinks RewriteEngine on RewriteCond %{HTTP_HOST} ^domain.com [NC] RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301] But i'd like to add another rule for shopping cart pages, to force http into https...
reizer
1

votes
2

answer
95

Views

php and htaccess to add vanity to a url with multiple levels

I have an .htaccess file which I am using to hide php extensions and add vanity to a directory. For example the users profile page would display: mydomain.com/usersname instead of mydomain.com?user=username This works fine as does the hiding .php extensions, this comes in handy for error pages or...
Paul Ledger
1

votes
3

answer
49

Views

htaccess securing files from being accessed by users

So, I'm sure this question gets asked quite a lot around here, but after a good 20 mins searching, I haven't been able to find any questions that produce the correct result. I have files, such as /index.php and /dashboard.php which use resource files such as /framework/assets/stylesheets/index.css e...
Ryan
1

votes
1

answer
39

Views

Migrating my site to HTTPS

I installed SSL on my server, works great. Let's say I have 10 html/php pages. Here's where I'm confused as to what's best for SEO: In my .htaccess file, am I doing a site wide (for all 10 pages) 301 redirect: RewriteEngine On RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^(?:www\.)? (.*...
user1040259
1

votes
2

answer
684

Views

Gzip working for html, but not javascript or css (Apache)

On my site, the html files are gzipped. However, the javascript, css, and svg files are not. The server uses Apache/2.2.22. I'm using the .htaccess file from HTML5boilerplate. Here's the relevant section: AddOutputFilterByType DEFLATE 'application/atom+xml' \ 'application/javascript' \ 'application/...
mattstuehler
1

votes
1

answer
64

Views

Using multiple databases for different endpoints

I have API written in lumen(laravel). I am using Eloquent for my models. What I need to do is to use different databases based on url (endpoint). For example I have http://apiprovider.com/api/v1/ as base API url and it connects to the api_v1 database, but I need to use another database if v2 is use...
CROSP
1

votes
1

answer
325

Views

Nginx url rewrite in two folders

In Apache I have a .htaccess file in the root to rewrite URL's with an exception to a folder called admin. In the admin folder I have another .htaccess file to rewrite URL's in that folder. How can I achieve the same using a nginx server block? This is the snippet I currently use for URL rewriting i...
Asa Carter
1

votes
1

answer
376

Views

.htaccess show 404 error if url has extra slashes

This is my URL structure http://example.com/filename-.html .htaccess RewriteEngine on RewriteBase / RewriteRule ^filename-([0-9]+)\.html$ filename.php?id=$1 [L] RewriteRule ^(.*)\.html$ $1.php [L] ErrorDocument 404 /404.html issue is that if there is a wrong url it doesn't go to 404 error page Exam...
max
1

votes
1

answer
124

Views

What does “(?s)” mean to htaccess?

While reviewing the documentation of a popular framework, I stumbled upon the .htaccess code below. I pretty much understand what it does except for the (?s) part. What does it do? RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^((?s).*)$ index.php?_url=/$1 [QS...
Jeff
1

votes
1

answer
879

Views

Rewrite url for Angular app within sub-folder

I've got an Angular app using html5mode, but it's currently sitting within a sub-folder of a site: http://somesite.com/za/ So I've managed to rewrite the url to direct to my assets folder correctly, but I'm still getting 404s when I hit refresh or navigate directly to a page. So this works: http://s...
Mike Hanslo
1

votes
1

answer
23

Views

.htaccess not every rewriterule works

I have the following .htaccess file Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [R=301,L] RewriteRule ^help$ /pages/help/index.php [NC] RewriteRule ^help/search$ /pages/help/search...
samleurs
1

votes
1

answer
27

Views

Query String Redirect

Looking to create a short url tool and want to be able to go to; www.website.co.uk/j2ExICY and actually load www.website.co.yk/?u=j2ExICY however keeping the url as www.website.co.uk/j2ExICY the whole time. Do you know how to control this through the .htaccess?
Kieran Headley
1

votes
1

answer
51

Views

Need help understanding contents of a .htaccess file

I'm working on a blog using Wordpress and I can't figure out what the .htaccess file it creates is doing. Here is the contents of the file: # BEGIN WordPress RewriteEngine On RewriteBase /welg/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Rew...
SimonT
1

votes
1

answer
921

Views

Wordpress cloudflare upload limit

So currently I'm running latest version of wordpress, apache 2.2 and cloudflare. The thing is I want to upload files larger than 100MB (this is free cloudflare limit for uploads) by using wp-admin. I have tried to add page rule for /wp-admin/* and disable everything I can, but I still can't upload a...
Robertas
1

votes
1

answer
33

Views

Is there anyway to write 1 single rule to redirect multiple dynamic URLS

Hey everyone I search around for this answer but could only find ways to redirect each URL individually. My old site urls were like this: www.domain.com/show_detail.php?item=item_description_of_various_lengths new URLs are like this: www.domain.com/shop/brands/titan/item_description_of_various_lengt...
Zab Allah
1

votes
1

answer
648

Views

RewriteRule to match anything alphanumeric or dash only

I am trying to write a rule that matches domain.com/abc RewriteRule ^([^/\.]+)?$ results.php?category=$1 [L,NC] This works and category=abc but this rule also seems to be triggered if I just go to domain.com I need my rule to only match if the URL after the slash contains alphanumeric characters or...
Chris
1

votes
1

answer
37

Views

http to https redirect htaccess not working

I found a lot of similar answers but so far I could not manage the right thing that I want. It seems very easy or maybe somebody already answered but for me it's not working anymore.. So at the end I want https://example.com/product/624567 In my htaccess file I have already a rule something like th...
TheLittleHenry

View additional questions