.htaccess

Force HTTPS on my rewrite and rule .htaccess file

ぐ巨炮叔叔 提交于 2021-01-28 02:32:27
问题 I would like to force https on my site but that it is compatible with the current rule of my .htaccess Here is my htaccess file at the moment : RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] Thanks 回答1: Could you please try following, where you need to look for condition if variable %{HTTPS} is on or not, add this condition with already existing condition. Also please don't mix it with already existing URL as it may get expose to client

How to properly make 301 redirect

安稳与你 提交于 2021-01-28 00:15:26
问题 I have over 50 html pages that I'm going to move to different folders in the same domain. How to properly make 301 redirects for each one? Some people said to place the redirect in meta html tags. Like this <meta http-equiv="refresh" content="0; url=http://example.com/" /> Some other people are saying to make it inside the .htaccess file, I'm not sure what's the best way? My goal is to redirect the old URLs to the URLs without losing the page rank in Google. 回答1: In most instances, a 301

mod_rewrite: Trailing slash on URL with two GET variables

坚强是说给别人听的谎言 提交于 2021-01-28 00:04:41
问题 I'm in the process of overhauling one of my projects, a web based booking system, but I'm having a bit of an issue with my htaccess file. The old system was pretty standard, with .php scripts in the route of the website, I had a rule hiding my extensions, and I resultantly had a URL like /viewinvoce?ID=1. I've been trying to find out how to rewrite this URL so it looks a lot neater - in the format /viewinvoice/1, and I'm getting there, but I have a slight problem... The URL /test works - it

Stylesheet is sent with a wrong mime type using node.js, how do I fix that?

牧云@^-^@ 提交于 2021-01-27 23:43:09
问题 node.js/express code var express = require('express'), app = express(), port = process.env.PORT || 3000, path = require('path'); app.use('/public', function (req, res) { res.sendfile(path.join(__dirname + '/public/index.html')); }); app.use('/', function (req, res) { var data = '<h1>hello world</h1>'; res.writeHead(200, {'Content-Type': 'text/html'}); res.end(data) }); app.listen(port); console.log('server started at port %s ', port); html <!DOCTYPE html> <html lang="de"> <head> <meta charset

.htaccess login and redirect based on username and password

夙愿已清 提交于 2021-01-27 21:59:25
问题 Been searching around for a .htaccess code but I just couldn't find the right one. I have a website which is password protected by .htaccess. What I need now is to redirect users (after they login) based on their username and password. ie. user1 with password:xxx would be redirected to mysite.com/page1, user2 with password:xxx would be redirected to mysite.com/page2 and user3 with password:xxx would be redirected to mysite.com/page3 Can this be done with .htaccess and if so, what the code

htaccess rewrite returns 404 not found

本小妞迷上赌 提交于 2021-01-27 21:15:26
问题 I want it so that if the user types webaddress.com/artist/P1/P2/ it will make it use /artist/index.php?artist=P1&am=P2 P1 would be an artist name, so it could contain both letters and numbers. P2 would be a number, so just numbers. I want it so that P1 would be esssential, whereas P2 isn't because right now it just returns 404 not found on that address. Current code: RewriteEngine on RewriteRule ^artist/([^/]+)/(\d+)/$ /artist/index.php?artist=$1&am=$2 [L] 回答1: /artist/index.php implies there

Htaccess - Rewrite and Redirect URL with PHP GET variable

此生再无相见时 提交于 2021-01-27 21:10:35
问题 I am trying to both rewrite and redirect this URL: https://www.domain.com/video-lessons-page.php?item=stocks to go to this URL: https://www.domain.com/stocks-video-lessons Here is the code I'm currently working with: RewriteCond %{QUERY_STRING} ^item=([^&]+) RewriteRule ^/?video-lessons-page\.php$ https://www.domain.com/%1-video-lessons? [R=301,L] RewriteRule ^(stocks|finance|accounting)-video-lessons$ video-lessons-page.php?item=$1 [NC,L] Unfortunately with the above code I'm having issues.

How can I rewrite query parameters to path parameters in Apache?

爱⌒轻易说出口 提交于 2021-01-27 18:37:43
问题 I currently have a website that I am trying to optimize in terms of SEO. I've got the site working with URLs such as: domain.com/?app=about In my app, $_GET[app] is set to 'about', as expected. Now, I want to make it so that a URL like domain.com/about is treated as if it were domain.com/?app=about . How can I do this in an Apache .htaccess file? 回答1: These are known as RewriteRule s, and they are fairly straightforward: RewriteEngine on RewriteRule ^about$ /index.php?app=about Here's the

Prestashop Webservice api url redirection

邮差的信 提交于 2021-01-27 14:12:03
问题 I'm trying to run a simple webservice to get a XML list of customers but, when getting http://www.myshopurl.com/api/customers, PS redirects to frontpage. Mod_rewrite is on in apache (checked with phpinfo function). Think that .htaccess is well formed: # ~~start~~ Do not remove this comment, Prestashop will keep automatically the code outside this comment when .htaccess will be generated again # .htaccess automaticaly generated by PrestaShop e-commerce open-source solution # http://www

Only allow access to PHP scripts from a form, not directly

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-27 13:20:22
问题 Being a novice with PHP, I may not be taking the correct route with forms but this way works for me, up to a point. Below is an example of my setup/ I have a form at www.foo.com/add.php, which needs an admin to be logged in to the session. The form inserts data into a database. Once it is submitted, the actions is set to action="scripts/add.php" and then that is redirected using a PHP header function to www.foo.com/done.php . What I want to know is, can you deny access to the script file