mod-rewrite

What is the difference in operation between . and ^ and ^(.*)$?

梦想的初衷 提交于 2019-12-31 04:25:14
问题 What is the difference in operation between: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ index.php [L] and RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] and RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php [L] I know that "." means any character and "^" beginning of string. Thanks for reply! 回答1: First let's understand how landing page is matched.

Mod_rewriting a query string onto a swf file

强颜欢笑 提交于 2019-12-31 04:18:08
问题 I'm attempting to use mod_rewrite to clean up the URL's to a flash video player. First, here is the original URL that I'm trying to rewrite to: library/player.swf?path=path-to-file.flv The above URL works perfectly fine when I access it directly. I have coded the swf to automatically grab the path parameter and play the video. No problems there. Now here is my attempted rewrite rule: RewriteRule ^player/(.+)$ library/player.swf?path=$1 [QSA,L] When visiting the url player/path-to-file.flv, I

How to convert text to lowercase URLs using .htaccess

北战南征 提交于 2019-12-31 04:04:06
问题 I want to set up 301 redirects in my .htaccess file so URLs like http://example.com/Foo http://example.com/Foo/Bar http://example.com/Foo/Bar/Blah change to http://example.com/products/foo http://example.com/products/foo/bar http://example.com/products/foo/bar/blah There are a discrete number of "Foo" cases which I can target with RewriteRule ^Foo, but how to append the "products" part? 回答1: First add this line in <VirtualHost> section OR at the end of your httpd.conf file: RewriteMap lc int

.htaccess RewriteRule not working, need to generate a URL friendly

若如初见. 提交于 2019-12-31 03:55:07
问题 I have this dynamic link: http://www.nortedigital.mx/article.php?id=36175&t=dobla_las_manos_el_snte__avala_reforma_educativa and I need to convert in URL friendly like this: http://www.nortedigital.mx/36174/se_enriquecio_elba_en_sexenios_del_pan.html and i have this RewriteRule: RewriteRule ^([^/]*)/([^/]*)\.html$ /article.php?id=$1&t=$2 [L] but doesn't work. Please, anybody can help me? 回答1: You must capture the query string in a RewriteCond and use that in the RewriteRule RewriteEngine On

Redirect subfolder to root and hide it in the url

点点圈 提交于 2019-12-31 03:49:05
问题 I have managed to "rebase" the root from a directory in order to keep public files separated from configs, helpers, and controllers, thanks to this answer and this answer. However I realized that if a user type http://domain.com/public it will not redirect to http://domain.com this is harmful for SEO because robots will treat them as two urls thus duplicate. I need to 301 redirect /public to root but as long as I am trying. It doesn't work. My htaccess looks like the following: # Options

iPad/iPhone browser sniffer with mod_rewrite and redirection; “too many redirections”

吃可爱长大的小学妹 提交于 2019-12-31 03:04:08
问题 I'm trying to create a browser sniffer for Mobile Safari version, the problem is that the redirection creates an infinite loop, obviously, and I'm wondering if there's a way to do this: http://mydomain.com (or any other requets_uri) [301]-> http://mydomain.com/ipad Here's the snippet I'm using: RewriteCond %{REQUEST_URI} !^ipad #Trying to set the condition "if /ipad is not the request_uri, but it doesn't work RewriteCond %{HTTP_USER_AGENT} .*Mobile.*Safari RewriteRule ^(.*)$ ipad [R=301,L]

htaccess 301 redirection for the bots

做~自己de王妃 提交于 2019-12-31 02:59:05
问题 I need help in .httaccess rewrite rule. One of my client says "A website abc.com should send traffic (with 301 redirect) from google, bing and yahoo search engigne bots only to cba.com otherwise show index.html (its a white page) i.e if Google robot is crawling abc.com it should see a redirect to bcd.com instead of the real content". is this possible like this? RewriteEngine On RewriteCond %{HTTP_USER_AGENT} Googlebot [OR] RewriteCond %{HTTP_USER_AGENT} msnbot [OR] RewriteCond %{HTTP_USER

Set up CakePHP in a subdirectory; Wordpress is installed in the root

断了今生、忘了曾经 提交于 2019-12-31 02:30:09
问题 I have been searching for a solution for 2 hours but nothing seems to work... here is my problem: I have WordPress installed in the root (var/www). So by going to http://www.geekderek.com, I see my wordpress site. I put CakePHP in a subdirectory var/www/cakephp. I want to be able to see my CakePHP app by going to: www.geekderek.com/cakephp. However, currently this url just returns a Wordpress page saying "Content not found." I believe this problem can be solved by modifying .htaccess in my

how to redirect to a subfolder and then rewrite subfolder link to root in htaccess?

扶醉桌前 提交于 2019-12-31 02:24:17
问题 I am sorry if this question is a duplicate but everything I looked for online confused me a lot so I am posting again this question specifying my needs. Since I want the structure of my website to be clean, I want to separate content from configurations, so I am putting all pages in the /app folder (much like a rails app). The structure of the website would be pretty much like this: . ├── app │ ├── index.php │ └── products │ └── index.php ├── configs └── layouts I found out how to redirect

What is redirect:// in PATH_TRANSLATED?

左心房为你撑大大i 提交于 2019-12-31 02:15:42
问题 I have a .htaccess rule that passes requests for /category/category-slug/ to category.php . However, when I inspect the $_SERVER super-global, I get this entry: Array ( [PATH_TRANSLATED] => redirect:// ) What is that? I’ve never seen redirect:// before. This is the relavant .htaccess rule: RewriteRule ^category/([^/]+)/?(.*) /category.php?cat=$1&page=$2 [L,QSA] As a result, I’m not getting $_GET['cat'] or $_GET['page'] populated in my script as it seems to be coming from a redirect and not