.htaccess

Redirect only with specific domain

六月ゝ 毕业季﹏ 提交于 2020-01-03 17:09:24
问题 I have a website with 2 different domains, for example: www.example.com www.example.net Now i want, that every user coming from example.com should be redirected to www.example.de Ill tried: RewriteEngine On RewriteCond %{HTTP_HOST} !^example\.com$ RewriteRule ^.*$ http://example.de/$0 [L,QSA,R=301] But now still all users from example.net get redirected to example.de How can i solve that, that only users from example.com gets redirected (also with all subfolders). Thanks! 回答1: Try this - you

HTAccess LocationMatch Server Error

断了今生、忘了曾经 提交于 2020-01-03 14:02:05
问题 I'm trying to use this .htaccess to change the RewriteBase if the location is local or live server. Options +FollowSymlinks RewriteEngine on <LocationMatch "^/(bbtsrv02)/$"> #RewriteBase /beta/admin/ </LocationMatch> RewriteCond %{REQUEST_URI} !index.php$ RewriteCond %{REQUEST_URI} !css/(.*)\. RewriteCond %{REQUEST_URI} !img/(.*)\. RewriteCond %{REQUEST_URI} !incs/(.*)\. RewriteCond %{REQUEST_URI} !js/(.*)\. RewriteCond %{REQUEST_URI} !upload/(.*)\. RewriteCond %{REQUEST_URI} !widget/(.*)\.

Changed the AllowOverride to All and still nothing

匆匆过客 提交于 2020-01-03 11:45:12
问题 I tried to write a .htaccess file on my local pc's website, I've realized I need to set AllowOverride All instead of None searched, found the file /etc/apache2/conf.d/security in the file I found #<Directory /> #AllowOverride None #Order Deny,Allow #Deny from all #</Directory> changed it to <Directory /> AllowOverride All Order Deny,Allow Deny from all </Directory> typed service apache2 restart and... .htaccess still didn't work :I the file by the way, holds one line, deny from all. 回答1:

.htaccess rewrite pretty urls that can still use get variables

橙三吉。 提交于 2020-01-03 09:47:21
问题 I'm trying to write an .htaccess line that will rewrite to a php script but still allow any extra get variables to be added on the end. Is this possible? Currently I'm trying to use this: RewriteRule ^item/([^/]*)([^/]*)$ /item.php?id=$1&$2 [L] The aim is to be able to do things like blah.com/item/foo , but also blah.com/item/foo?bar=whatever . Currently it seems to correctly pass the first part, id , but not the rest. 回答1: RewriteRule ^item/([^/]*)([^/]*)$ /item.php?id=$1&$2 [L,QSA] You can

How to turn dynamic URL into static URL

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-03 09:03:28
问题 I am developing a website using PHP and Apache. I wanna turn my URLs from www.example.com/book.php?book=title into something like this, if it is possible of course: www.example.com/book/title Notice that the title of the books are unique and cannot be repeated. I`ve read about this, but none of the posts were clear enough for a beginner like me. Do you guys know any tutorial that explains that? Thanks. 回答1: Expanding on @Rodolphe's and @Galen's replies a little bit. If your needs for url

Zend Framework in a subfolder

十年热恋 提交于 2020-01-03 06:06:00
问题 I have installed a Zend Framework application in a subfolder, something like this: www.mydomain.com/temp/zend-application/ Now the problem is all stylesheets, javascript files and also all links use relative paths, such as: /css/styles.css /js/jquery.js /controller/action And these go to the main domain like this: www.mydomain.com/css/styles.css www.mydomain.com/js/jquery.js www.mydomain.com/controller/action So how to make it work in that subfolder? My .htacces file looks like this now:

How can I set CORS access for an audio file on my Linux webserver with apache2?

我们两清 提交于 2020-01-03 06:02:05
问题 I am trying to create an audio visualization project on codepen. I tried hosting the audio file with OneDrive, but I was receiving CORS restriction errors. Now I have gone a step further and created my own web server (http://publicwebserverdemo.hopto.org) where I have the audio file hosted (http://publicwebserverdemo.hopto.org/publicAudio/audio.mp3). I have tried several sets of instructions across the internet for implementing CORS with the .htaccess file but I haven't had any luck with that

.htaccess regular expression issue

妖精的绣舞 提交于 2020-01-03 05:58:13
问题 I still have no answer about this so I'm posting it here. I want to match an url in the form of root/language/sub/.../document in a .htaccess file and then rewrite it as root/sub/.../document.php?lang=language Im close to hit but it seems my regexp doesn't 'catch' the input url. Here it is : RewriteCond %{REQUEST_FILENAME} !-d RewriteCond ^[a-z]{2}.*$/%{REQUEST_FILENAME}\.php -f RewriteRule ^([a-z]{2})/(.*)$ $2.php?lang=$1 Can someone point me out what is wrong here ? I'm no expert in regexp

.htaccess rewrite url - show html file as jpg

大憨熊 提交于 2020-01-03 05:58:11
问题 I have image.html and I want It to be shown in browser as image.jpg, because there are some operations when showing picture, that can't be done before or after. Is it even possible with .htaccess and url rewriting? I tried RewriteEngine On RewriteBase / RewriteRule ^image\.html$ image.jpg but without any luck. Thanks for all answers 回答1: First of all, you'll need let's say a PHP script. Call it image.php . After that, use a GET parameter to handle the image name. Let's call it name . To call

Optimize htaccess Wildcard Subdomain Code

允我心安 提交于 2020-01-03 05:50:09
问题 I have Wildcard Subdomains working perfectly on my server, but would like to optimize the .htaccess code to make it more portable. I'm not sure how to do it. I would like to replace the specific domain name and extension (DOMAIN and .com in the code below) with a regex match so that when using the wildcard code for other domains it is easy to port. So it should be a drop in replacement for domain.com and domain2.net . Here's the code I use: # Wildcard Subdomain RewriteCond %{HTTP_HOST} ^(www.