.htaccess

Force file to download with .htaccess

不想你离开。 提交于 2020-01-06 03:02:14
问题 So I am using the following rule in the htaccess: AddType SCHM wsc <FilesMatch "\.(wsc)$"> ForceType SCHM Header set Content-Disposition attachment </FilesMatch> But when I go to the file's location it doesn't force the download 回答1: Since the question is already answered in the comments, this is just to provide an answer in the way how Stackoverflow designated it. Like in the question it can be solved by using mod_headers of Apache 2 . Since Content-Disposition is not part of the standard of

htaccess file to remove folder, and replace underscores with dashes

情到浓时终转凉″ 提交于 2020-01-06 02:55:06
问题 I need to change the following url http://somedomain.com/news/a_sample_news_article.html to http://somedomain.com/post/a-sample-news-article I have this in my htaccess which works, but I am sure it can be improved upon - does anyone have a better solution? RewriteEngine on # replace underscores RewriteRule ^(news)/([^_]*)_+(.*)$ /$1/$2-$3 [L,NC,R=302] # redirect the directory from news to post RewriteRule ^news/(.*)$ /post/$1 [R,L] # remove .html from end of url RewriteRule ^(.*)\.html$ /$1

.htaccess non-www to www and http to https

江枫思渺然 提交于 2020-01-06 02:50:12
问题 I know this question has been asked and answered many times but I've spent the last 3 hours going through peoples answers and none have seemed to work just right for me. I need some .htaccess code to do this: If domain is example.co.uk/$urlData (only apply to main domain and no subdomains) rewrite too www.example.co.uk/$urlData If HTTPS is not "on" and domain is primary (ie. no subdomains) then redirect to https://www.example.co.uk/$urlData . I have to use RewriteCond %{HTTP:X-Forwarded-Proto

CSS, Images, and JS not loading due to url rewrite

牧云@^-^@ 提交于 2020-01-06 02:46:04
问题 I'm having trouble with css and images loading the moment my url ends in a /. I'm working off my localhost and the urls are rewritten in the form: localhost/mysite/public/user/testuser/books/1234 With the request loading the user profile page of testuser and changing the page state to focus on a book with the id 1234. Everything works fine with localhost/mysite/public/user, but the moment I introduce a / or /testuser to the url the CSS, JS, and Images break. I do have url rewriting in place

.htaccess redirect www to non-www not working

时光怂恿深爱的人放手 提交于 2020-01-06 02:23:14
问题 I pretty much know nothing about about .htaccess editing or regex expressions. What I have done to try to make my site re-direct from www versions to non-www versions is I followed the answers posted here: redirect www to non-www However, what I get is that if I enter www.example.com , I get: example.com/example.com/ and a 404 error on my site This is my .htaccess file: #Adjust default time zone SetEnv TZ America/Toronto #Begin redirect www to non-www RewriteEngine On RewriteBase /

How to redirect http to https and https://www to https://

时光怂恿深爱的人放手 提交于 2020-01-06 02:18:40
问题 I need help with rewrite rules. So I want that these addresses: http://domain.com http://www.domain.com https://www.domain.com Redirect to: https://domain.com Can someone help me? Right now I have rule: RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://domain.com/$1 [R,L] But it doesnt redirect https://www to https:// 回答1: Place this rule in your DOCUMENT_ROOT/.htaccess file: RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} www\. RewriteRule ^ https://domain.com%

htaccess URL rewrite space replacement

百般思念 提交于 2020-01-06 02:08:05
问题 EDIT NOTE: Modified code to Documentroot I am doing rewrite rules for a client's website and I started with my own website's blog rewrite rules, as they kinda match the customer needs. Now that every rules are modified to the client needs, I'm glad it is working super fine. Here is the final look; Options +FollowSymlinks RewriteEngine on # executes repeatedly as long as there are more than 1 spaces in URI RewriteRule "^(\S*)\s+(\S*\s.*)$" /$1-$2 [L,NE] # executes when there is exactly 1 space

I want to redirect all http requests to https, and all www requests to non-www

谁说我不能喝 提交于 2020-01-06 01:57:31
问题 Here is my current .htaccess file: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php </IfModule> I want to redirect all http requests to https, and all www requests to non-www, and all file requests to index.php For example: http://www.example.com to https://example.com https://www.example.com to https://example.com

I want to redirect all http requests to https, and all www requests to non-www

帅比萌擦擦* 提交于 2020-01-06 01:57:13
问题 Here is my current .htaccess file: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php </IfModule> I want to redirect all http requests to https, and all www requests to non-www, and all file requests to index.php For example: http://www.example.com to https://example.com https://www.example.com to https://example.com

.htaccess rewrite rule for two GET variables on index.php?

我与影子孤独终老i 提交于 2020-01-06 01:08:11
问题 I'm trying to do a rewrite but I couldn't find it or do it myself. I'm trying to convert http://www.homepage.com/variable1/variable2 to http://www.homepage.com/index.php?var1=variable1&var2=variable2 or http://www.homepage.com/?var1=variable1&var2=variable2 I have tried RewriteRule ^/(.*)/(.*)$ ?var1=$1&var2=$2 [NC,L] RewriteRule ^(.*)/(.*)$ ?var1=$1&var2=$2 [NC,L] RewriteRule ^/(.*)/(.*)$ index.php?var1=$1&var2=$2 [NC,L] RewriteRule ^(.*)/(.*)$ index.php?var1=$1&var2=$2 [NC,L] none of these