mod-rewrite

htaccess Options +FollowSymLinks giving me 500 internal server error

喜欢而已 提交于 2019-12-18 05:48:06
问题 This htaccess was working, then i just open it and then close. when i refresh my browser. it's 500 internal server error. I'm sure that my mod_rewrite is on. Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\.html$ index.php?page=$1 [L,QSA] Did i do something wrong here? or any suggestions or comments? 回答1: Make sure you have AllowOverride Options privileges to use Options. 回答2: I had same problem

mod_rewrite: Pass the path & query string URL as a parameter

半城伤御伤魂 提交于 2019-12-18 05:18:28
问题 I'm using mod_rewrite to rewrite pretty URLs to a form supported by a Spring 2.5 application. e.g. /category/cat1?q=x => /controller?category=cat1&q=x However from my controller I want to know the original URL the request came from (so I can generate a link if required). This approach is needed generically across all pages so it is difficult to hard code. How can I access the original path + query string from my controller? I have tried using $0 to include the full path but this doesn't

Rewrite rule for user agent with mod_rewrite

橙三吉。 提交于 2019-12-18 04:51:04
问题 I'm trying to redirect all requests to a domain from a particular user-agent to a subdomain. My rule is as follows: RewriteEngine on RewriteCond %{HTTP_USER_AGENT} ^Test Agent/(.*)$ // <-- Line 4 RewriteRule ^(.*)$ https://test.domain.com/$1 [L,302] But all I get when starting the web server is: Syntax error on line 4 of /var/www/misafe/internal/misafe-old.conf: RewriteCond: bad flag delimiters It looks OK to me but I'm obviously missing something and the error is not helping much. Any ideas?

Using .htaccess to control HTTPS on certain pages

*爱你&永不变心* 提交于 2019-12-18 04:09:42
问题 I've got a site that requires (obviously) HTTPS for checkout. The current fix put in place involved making the whole site run in SSL mode, but this is causing problems. How would I change this... RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L] To only set a certain URL (say basket.php) as HTTPS? 回答1: I beleive this would work: RewriteCond %{HTTPS} off RewriteCond %{REQUEST_URI} /basket.php RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L] 回答2: A shorter

MOD_REWRITE for URL variables, removing empty parameters and using more than 1field for the first and second variables

我怕爱的太早我们不能终老 提交于 2019-12-18 03:44:24
问题 I have a previous question that was answered very well but requires an amendment and I was unable to reply so have created a new question. I required a mod_rewrite that made the following: www.example.com?page=var1&cat=var2&subcat=var3&subsubcat=var4 into this: www.example.com/var1/var2/var3/var4/ but that also covered the optional use of var2, var3 and var4 so if those variables were empty, it would still work. The question was answered very well but it requires an amendment to work with

setting up laravel on IIS7

对着背影说爱祢 提交于 2019-12-18 01:20:14
问题 I want to set up my IIS7 server in order to let it works with a web application written in laravel (php framework). I found something similar for CI (link) but it doesn't work on laravel (of course I removed the index.php redirection). actually only home page works ( www.mysite.com/public ) anybody uses/d IIS7 with Laravel? thanks in advance 回答1: I created the web.config file in root folder inside <configuration></configuration> : <system.webServer> <defaultDocument> <files> <clear /> <add

RewriteRule Error: Bad flag delimiters

蓝咒 提交于 2019-12-17 22:56:48
问题 Using this RewriteRule in my .htaccess file I'm getting RewriteRule: Bad flag delimiters which is returning a 500 error in the browser. Can anyone point me in the right direction please. Thanks. RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com [NC] RewriteRule ^dev/(.*)$ http://dev.example.com/$1 [L,R=301, NC] This is on Ubuntu on a Digital Ocean Droplet. 回答1: Turns out it was because of the space before N in the flag declaration [L,R=301, NC]. I changed it to [L,R=301,NC] and now it

Replace portions of a url path and query string using .htaccess and Regex?

我们两清 提交于 2019-12-17 22:01:03
问题 How do I replace : https://www.example.com/index.php?option=com_k2&view=item&id=7377 By: https://www.portal-gestao.com/artigos/7377 I tried this : RewriteRule ^index.php?option=com_k2&view=item&id=(.*)$ /artigos/$1 [R=301,L] And this: RewriteRule ^index.php?option=com_k2&view=item&id=\/([0-9]{4}-.*)$ /artigos/$1 [NC,R,L] 回答1: You cannot capture query string in RewriteRule . Use a RewriteCond instead. Use this rule at top of your .htaccess: RewriteCond %{THE_REQUEST} /index\.php\?option=com_k2

mod_rewrite URL info required

余生长醉 提交于 2019-12-17 21:33:09
问题 I am new to this mod_rewrite. I have been successfully able to rewrite the URL something like this: http://mydomain.com/products/12 to this: http://mydomain.com/products.php?prodId=12 But when I give http://mydomain.com/products/12 in the address bar, the css and js files are not loaded. But when I access http://mydomain.com/products.php?prodId=12 the js and css get loaded properly. Please let me know if I am missing something. My .htaccess looks like this: Options +FollowSymlinks

Mod Rewrite : Replace all _ (underscore) with - (hyphen)

淺唱寂寞╮ 提交于 2019-12-17 21:23:19
问题 I need to have all _ (underscores) in every url to be replaced with - (hyphens) I currently do it this way, but am looking for a more simpler way of doing this so I do not have to add a line every time a url gets longer. RewriteRule ^([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^.]+)-([^.]+)-([^.]+)-([^.]+)$ index.php?/$1_$2_$3_$4_$5_$6_$7_$8_$10 [L] RewriteRule ^([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^_]+)-([^.]+)-([^.]+)-([^.]+)$ index.php?/$1_$2_$3_$4_$5_$6_$7_$8_$9 [L] RewriteRule