mod-alias

Using RedirectMatch with HTTP_HOST in the destination

霸气de小男生 提交于 2020-06-10 18:56:49
问题 I keep reading that, where possible, I should not be using mod_rewrite . As such, I am trying to do a http to https rewrite with RedirectMatch. Question: How can I use RedirectMatch and use Apache server variables (such as %{HTTP_HOST} ) in the URL parameter? This code fails to return a response to the client (Chrome): RedirectMatch ^(.*) https://%{HTTP_HOST}/$1 I recently asked a similar question to this, but it may have been too wordy and lacks direction for an answer: Redirecting http

Using RedirectMatch with HTTP_HOST in the destination

核能气质少年 提交于 2020-06-10 18:56:41
问题 I keep reading that, where possible, I should not be using mod_rewrite . As such, I am trying to do a http to https rewrite with RedirectMatch. Question: How can I use RedirectMatch and use Apache server variables (such as %{HTTP_HOST} ) in the URL parameter? This code fails to return a response to the client (Chrome): RedirectMatch ^(.*) https://%{HTTP_HOST}/$1 I recently asked a similar question to this, but it may have been too wordy and lacks direction for an answer: Redirecting http

AliasMatch With Regex NotWorking in Apache 2.4

浪子不回头ぞ 提交于 2020-01-16 00:39:08
问题 I used to have Alias as below for /CollabPortal14300 which was working fine Alias /CollabPortal14300 D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/ Alias /dc/api/entity/EmailDocument/\d+/DocumentVersion/1\.0 D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/core/html/blank.html <Directory D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal> Options Indexes FollowSymLinks Includes ExecCGI Require all denied <FilesMatch "\.(gif|jpe?g|jpg|png|js|css|ico)$">

Apache Redirect Permanent For URL with Data in String (Question Mark)

有些话、适合烂在心里 提交于 2020-01-06 14:27:24
问题 I am looking for an Apache redirect where the source URL has a question mark in it. Redirect permanent /course/view.php?id=68 http://exmaple.com/page.php I've tried escaping the question mark, but that doesn't work. I've read a couple pages on the web about using Rewrite conditions, however it didn't quite make sense to me, or it was a little bit different than what I wanted to accomplish. 回答1: Try adding the following to the .htaccess file in the root directory of your site. RewriteEngine on

Dynamic Virtual Host with Dynamic Alias

百般思念 提交于 2019-12-24 00:24:01
问题 I am using DNSMasq for this setup. I am having issues with Alias, as it does not work at all for dynamic virtual hosts. And there's no such a thing as VirtualAlias in Apache documentation. I am trying to setup my new environment just like I did before for .dev tld, but I am having issues, because it require more configuration. Here's fully functional .dev Virtual Document. <VirtualHost *:80> ServerAlias *.dev UseCanonicalName Off VirtualDocumentRoot "/Users/nn/Sites/%1" </VirtualHost> Here's

Rewrite an Alias directory

谁说我不能喝 提交于 2019-12-23 09:09:52
问题 I'm trying to first use an Alias folder to store my project files in a different location than my DocumentRoot , and then execute a mod_rewrite on this request. However it doesn't seem to parse the .htaccess file. This is the content of my Alias file: Alias /test F:/Path/To/Project <Directory F:/Path/To/Project> Order allow,deny Allow from all </Directory> This is my .htaccess file: Options +FollowSymlinks RewriteEngine on RewriteRule .* index.php [NC] [PT] When I remove the Alias everything

Apache : How to Use Rewrite Engine Inside Alias

我们两清 提交于 2019-12-19 09:16:12
问题 I have this alias configuration: Alias /test/ "D:/WWW/Test/" <Directory "D:/WWW/Test/"> Order allow,deny Allow from all </Directory> Then inside D:/WWW/Test/ directory, I put .htaccess with the following configuration: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^([^.]*\.css)$ resources/$1 [L,NC] </IfModule> I just want to redirect all request from localhost/test/css/* to localhost/test/resources/css/* . But it seems that the .htaccess is ignored. Even if I put DirectoryIndex

Redirecting http traffic to https in Apache without using mod_rewrite

一笑奈何 提交于 2019-12-13 08:08:33
问题 I am trying a pretty simple thing that I would normally do using a RewriteRule (and which works perfectly when I do). My goal: Force certain (not all) URLs to use the https protocol. Caveats: Apache is behind a crypto-offloader. We would like a single virtual host that deals with both the unencrypted and the decrypted traffic. The offloader forwards all traffic to the same port and sets the X-Forwarded-Proto header. (It also sets the new Forwarded header for future compatibility, but I will

Simple mod_rewrite RewriteRule for messy legacy url's

帅比萌擦擦* 提交于 2019-12-12 02:47:01
问题 Launching a new website for a new client. Their old site has about 50 products and unfortunately, the old product names do not match up to the new URL pattern Old URL Examples: example.com/products.aspx?category=Foo&product=SuperLongNoBreakProductNameIDDescription example.com/products.aspx?category=Foo&product=ProductNameDescription&var1=1293.123 example.com/products.aspx?category=Bar&product=ProductCategoryProdNameRandomNumbers (The old URL's are sometimes hitting 150+ characters.) New URL's

Htaccess 301 Redirect a sub folder with exception

心已入冬 提交于 2019-12-11 04:38:32
问题 I would like to redirect to a sub-folder except a dir. What I need is: Redirect 301 /blog/ /blog-post/ #Exclude /blog/wp-admin/ 回答1: You need to use RedirectMatch : RedirectMatch 301 ^/blog/((?!wp-admin).+) /blog-post This will redirect everything except blog/wp-admin . If you are on apache 2.4 you can also use Redirect inside if directive <if "%{REQUEST_URI} !~ m#/blog/wp-admin/#"> Redirect 301 /blog/ /blog-post/ </if> 来源: https://stackoverflow.com/questions/38157262/htaccess-301-redirect-a