mod-rewrite

htaccess to strip www and force SSL

一个人想着一个人 提交于 2020-01-02 09:55:42
问题 I have what I believe to be a rather well crafted .htaccess file: RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L,NE] RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] This says to me "strip the www. off the url and force https." And it works fine except for those people who happen to type in https://www.somedomain.com/. Those people are presented with a warning that there is a problem with the site

Redirect subdomain request to subdirectory + https (using .htaccess)

∥☆過路亽.° 提交于 2020-01-02 09:10:15
问题 I've got some issues with a .htaccess that I just can't get to work. Hope someone could solve this one. I have a SSL certificate on the www.-domain on an Apache server. I want all http://subdomain.domain.com requests on a specified list of subdomains to redirect to https://www.domain.com/subdomain . The second problem is I don't have a wildcard certificate that works on non-www. requests, requests to https://subdomain.domain.com will result in an "Untrusted Connection" alert. So this also has

What does RewriteRule ^(.*)/$ ?path=$1 [QSA,L] mean in my .htaccess?

浪尽此生 提交于 2020-01-02 08:52:11
问题 I need to create rewrite in nginx as is done in my .htaccess and there are some lines which I don't completely understand. DirectoryIndex index.php RewriteEngine on RewriteCond % !-f RewriteRule ^(.*)/$ ?path=$1 [QSA,L] Can someone explain it to me? 回答1: RewriteCond % !-f seems incorrect rule condition and is always evaluating to true. This rule: RewriteRule ^(.*)/$ ?path=$1 [QSA,L] Is matching any URI with trailing slash and internally rewriting to /?path=uri-without-slash So for ex: an URI

mod_rewrite trailing slash with RewriteCond

被刻印的时光 ゝ 提交于 2020-01-02 08:32:53
问题 I have searched through the related mod_rewrite qustions but I can't anything specific enough so I'll post: Heres my rule that adds a trailing slash: RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$ RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L] Only I want to exclude one specific directory eg. /mydirectoryname/ and not add the trailing slash to anything that starts with that. Reason being its breaking some of my ajax calls. 回答1: Add another RewriteCond: RewriteCond %{REQUEST_URI} !

Mod Rewrite, pass parameters from URL1 to URL2

六眼飞鱼酱① 提交于 2020-01-02 08:23:13
问题 I'm trying to rewrite the following URL test.php?par1=foo&par2=bar Into... newtest.php?hidden_par=blah&par1=foo&par2=bar I have this rule, that does not work: RewriteRule ^test.php\??(.*?)$ newtest.php?hiden_par=blah&$1 [L] Could this be done using RewriteCond or something else? (say, could this be done ?), thanks in advance. 回答1: You probably want something like the QSA ("query string append") flag, which causes the remainder of the query string to be properly appended onto the end of the

How do I write SCRIPT_URI to a header in Apache?

橙三吉。 提交于 2020-01-02 08:12:05
问题 I have a setup where I have servers like this: load balancer -> Apache -> Tomcat I would like Apache to write the url that the client used into a header, so I can read that once I hit tomcat. I've tried to use mod_rewrite and mod_headers so do it, but with no luck. if I look at http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html then it seems clear that i need the variable called SCRIPT_URI: SCRIPT_URI=http://en1.engelschall.com/u/rse/ I also looked at this http://www.askapache.com/htaccess

How do I write SCRIPT_URI to a header in Apache?

試著忘記壹切 提交于 2020-01-02 08:11:29
问题 I have a setup where I have servers like this: load balancer -> Apache -> Tomcat I would like Apache to write the url that the client used into a header, so I can read that once I hit tomcat. I've tried to use mod_rewrite and mod_headers so do it, but with no luck. if I look at http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html then it seems clear that i need the variable called SCRIPT_URI: SCRIPT_URI=http://en1.engelschall.com/u/rse/ I also looked at this http://www.askapache.com/htaccess

How to remove empty parameter or parameters anywhere in URL by .htaccess?

感情迁移 提交于 2020-01-02 07:43:15
问题 Empty parameters that I mean can be anywhere in URL each time different place, each time with different name, each time on different php page e.g : http://www.example.com/AnyPHPpageHere.php?parameter1=7&parameter2=&parameter3=blue&parameter4= to the form: http://www.example.com/AnyPHPpageHere.php?parameter1=7&parameter3=blue So how to do it via .htaccess? 回答1: You can use this URL to remove any one or more empty parameters from anywhere in URLs: RewriteEngine On RewriteCond %{QUERY_STRING} ^(

Apache mod_rewrite enabled, but not working

谁都会走 提交于 2020-01-02 07:24:22
问题 Battling second day against problems with using mod_rewrite. System OS: Windows XP HTTP server: Apache 2.2 httpd couple related lines from httpd.conf LoadModule rewrite_module modules/mod_rewrite.so LoadModule proxy_module modules/mod_proxy.so DocumentRoot "N:/Web-dev/www" <Directory "/"> Options Indexes +FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all </Directory> <Directory "N:/Web-dev/www"> Options Indexes +FollowSymLinks MultiViews AllowOverride All Order allow

htaccess redirect index.html to index.php for domain root only

无人久伴 提交于 2020-01-02 07:01:07
问题 I have a htaccess rule which redirects the index.html to index.php RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/ RewriteRule ^(.*)index\.html$ /$1index.php [R=301,L] This works fine - when I call http://mydomainname.com/index.html , it redirects me to http://mydomainname.com/index.php but I got one problem, when there is a file in subfolder named index.html then my htaccess rule takes that to index.php. Example - http://mydomainname.com/subfolder/index.html to http:/