mod-rewrite

Rewrite request to a sub directory

我是研究僧i 提交于 2019-12-13 00:48:06
问题 I have a web application in a directory suppose xyz . I am trying to redirect all requests to a sub directory www . My current .htaccess code is: RewriteEngine On RewriteRule (.*) /www/$1 [L] But, when I visit http://example.com/xyz/some_url the request is redirected to http://example.com/www/some_url rather http://example.com/xyz/www/some_url which I want. Update: Sorry, I forgot to mention the directory xyz as in my case is likely to renamed. So, this directory doesn't need to be hard coded

Disabling compression for IE pre SP2 with Apache mod_rewrite

拈花ヽ惹草 提交于 2019-12-13 00:45:31
问题 I am trying to replicate this fix ( http://sebduggan.com/posts/ie6-gzip-bug-solved-using-isapi-rewrite ) with Apache mod_rewrite, but with no success... Can somebody help me translate those ISAPI rules to APACHE mod_rewrite? I don't know how to 'translate' those rules... My objective is to avoid sending compressed css and js when the user has an XP version prior to SP2, since there is a bug that prevents IE6&7 under SP1 to read the gzipped CSSs of my website BuscoUnViaje.com The rules I am

Combination of rewrites in .htaccess doesn't work

自古美人都是妖i 提交于 2019-12-13 00:45:06
问题 I have different rules in my .htaccess file which work fine individually but combined in one file they don't. Here are some examples of my file: # take care of %C2%A0 RewriteRule ^(.+)\xc2\xa0(.+)$ $1-$2 [L,NE] # executes **repeatedly** as long as there are more than 1 spaces in URI RewriteRule "^(\S*) +(\S* .*)$" $1-$2 [L,NE] # executes when there is exactly 1 space in URI RewriteRule "^productdetails/617/6/(\S*) (\S*?)/?$" /$1-$2/302 [L,R=302,NE] Also I've got the following: RewriteCond %

Redirect php page to another php page using 301 .htaccess

白昼怎懂夜的黑 提交于 2019-12-13 00:42:00
问题 I have a dynamic page that I need to redirect to another dynamic page in .htaccess. I have tried different syntax for the redirect but nothing seems to work: RewriteEngine on RewriteRule /index.php?p=page&page_id=store$ http://www.website.com/index.php [R=301] OR RewriteEngine on RewriteCond %{QUERY_STRING} ^p=page&page_id=store$ RewriteRule ^/index.php$ http://www.website.com/index.php? [L,R=301] EDIT: I have an old php page in the shopping cart that I have transferred to the new address. So

.htaccess rewrite keeps going after a match is made

主宰稳场 提交于 2019-12-13 00:41:15
问题 I'll preface this with the fact that htaccess and mod_rewrite aren't my best areas. I've written a php MVC framework for personal use, and in the document root I have a folder called "public" for css, js, images, etc. Every HTTP request is checked against the files in "public" and if it exists, it sends that file; otherwise it redirects to index.php for the framework. The rules work, but if a match is made in "public," it still routes to index.php. If I comment out the last line which

.htaccess URL redirection using User Agent

时间秒杀一切 提交于 2019-12-13 00:32:34
问题 I've been trying to find a solution to my situation but none worked. I have the following htaccess file which does the following: It redirects site.com/m/page to site.com/m/#page I redirects site.com/d/page to site.com/m/#page It deletes .php extension and the common_ pattern which I had in front of the pages The code so far: Options +FollowSymlinks -MultiViews RewriteEngine On RewriteBase / RewriteRule ^[dm]/(.+)$ /m/#$1 [R=302,NE,L,NC] ## hide .php extension RewriteCond %{THE_REQUEST} \s/

Rewrite rules showing in location bar of browser

别说谁变了你拦得住时间么 提交于 2019-12-13 00:15:15
问题 I have the following rewrite rules: <IfModule mod_rewrite.c> RewriteEngine on RewriteBase / # Route all URLs to dispatch.php. RewriteCond %{REQUEST_URI} !media/ RewriteRule ^(.*)$ dispatch.php [L] #Route requests to /media/* to /project/media/* RewriteRule ^media/(.*)?$ project/media/$1 [L] </IfModule> Everything is rewritten to dispatch.php unless the URI starts with media/ in which case it will rewrite the URI to project/media/* . Everything works fine and if I navigate to example.com/media

.htaccess redirect to https except admin url

本秂侑毒 提交于 2019-12-12 23:14:38
问题 I would like to redirect all frontend requests to secured site https and all admin / backend urls should remain unsecured http. In addition, I use Cloudflare CDN. My rewrite rules do not work, all queries go to https. RewriteCond %{HTTPS} off RewriteCond %{HTTP:X-Forwarded-Proto} =http RewriteCond %{REQUEST_URI} !admin RewriteRule ^ https://example.com%{REQUEST_URI} [L,R=301] Please help me. 回答1: It should work fine as you have it, although I would change: RewriteCond %{REQUEST_URI} !admin to

mod_rewrite Multiple Variables and Subfolders

♀尐吖头ヾ 提交于 2019-12-12 23:02:00
问题 On my site I have multiple URLs like this: Main Page: mysite.com mysite.com/?content=about mysite.com/?content=posts&page=2 Subfolders: mysite.com/subsite/ mysite.com/subsite/?content=about mysite.com/subsite2/?content=posts&page=2 I'd like to make clean these up to be: mysite.com/about/ mysite.com/posts/2 mysite.com/subsite/about/ mysite.com/subsite/posts/2 Now, I've been able to use mod_rewrite for one variable, and some other simple things, but I'm not exactly sure how to accomplish this.

htaccess prevent direct access to files while allowing rewrite rules to access them

ε祈祈猫儿з 提交于 2019-12-12 22:57:55
问题 General Overview I've been creating this really nice .htaccess file with a bunch of settings that work great so far. I am wondering if it is possible, now, to allow access to files through flat links only while denying access to the same files directly. Explanation & Current Settings To better present this question consider the following: I have a file: i.e. myFile.php Which is in a subfolder: i.e. my/path/to/file/ The file's full path would then be my/path/to/file/myFile.php Accessing this