mod-rewrite

Mod_rewrite is not including subdirectories

丶灬走出姿态 提交于 2019-12-24 21:19:23
问题 I have a mod_rewrite (mostly thanks to stack member Olaf) that redirects from index.php?URL=pages/the-page.php to simply the-page . The problem is, when a page is requested that isn't directly in pages (i.e., pages/sub ), it redirects my .css and .js which is no good. What I'm trying to accomplish is this: ONLY rewrite files in the pages folder, but include ALL subdirectores of it. An important thing is that it never, ever, ever rewrites the URL of the files folder. Here's the code: Options

.htaccess - Redirect subdomain and path to same subdomain and path on another domain

a 夏天 提交于 2019-12-24 21:06:56
问题 I have looked far and wide for a solution but haven't been able to find one that resolved my issue. I am trying to implement a 301 redirect that would redirect the user to another domain, with the same subdomain and path as the one they requested. i.e. if they land on sub1.domain1.com/page.php they get redirected to sub1.domain2.com/page.php. The redirect should catch ANY subdomain. I have set the AllowOverride to All on the /var/www/html directory and tried the following but with no luck:

URL Rewrite and redirect

一个人想着一个人 提交于 2019-12-24 20:38:30
问题 I am having a small issue, I want to place rewrite url and redirect rule both. For example, I want to show content of abc.php when someone open abc.html and this can be done with url rewriting: RewriteEngine On RewriteRule ^abc\.html$ abc.php [NC,L] But what if some one opens abc.php directly in browser, I want to send them on abc.html and when I place 301 redirect it doesn't work as it generates loop. How I can do this? 回答1: You can use: RewriteEngine On RewriteCond %{THE_REQUEST} /abc\.php[

Reuse subdomain in a rewrite rule

无人久伴 提交于 2019-12-24 18:34:05
问题 I'm a bit stuck with my redirect rule. Little example better than a long speech, here goes the Great Ugliness: IndexIgnore * ErrorDocument 404 http://www.example.com RewriteEngine on RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^([^\.]+)\.example\.com$ http://example.com/private/$1/public/si.php [L] My objective is to get the subdomain ([^\.]+) and use it in the redirection instead of $1 . For example, test.example.com should redirect to http://example.com/private/test/public/si.php

Mod-rewrite not working on Network Solutions server

走远了吗. 提交于 2019-12-24 17:53:12
问题 I have a website that requires mod-rewrite to function well, but it seems to not be functional on the Network Solutions shared server we're running on. Network Solutions promises it's installed but won't provide any further support without additional payment. I placed a simple test at the following folder which contains two files. The first, ".htaccess" contains the following text: RewriteEngine On RewriteRule ^link([^/]*).html$ rewrite.php?link=$1 [L] The second is the PHP script which tests

Apache RewriteRule: bad flag delimiters

左心房为你撑大大i 提交于 2019-12-24 17:50:01
问题 This is my .htaccess file # Redirect every request to index.php RewriteBase / RewriteEngine on RewriteRule .* to public/index.php And i'm receiving the following error in the error.log: RewriteRule: bad flag delimiters What's wrong with the .htaccess file? (I just started stying mod_rewrite module). Edit: the .htaccess file is in the site's root. 回答1: Remove " to ": RewriteRule .* public/index.php Documentation 回答2: AFAIK, you don't need a "to" in the rewrite rule. just delete that word and

RewriteRule for images

佐手、 提交于 2019-12-24 17:46:09
问题 I have to rewrite some url on my site. I've put this in my htaccess to make this change: http://example.com/john/?a=1&b=2 --> http://example.com/index.php?account=john&a=1&b=2 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9_-]+)/?$ ./index.php?account=$1 [NC,QSA,L] Now I have to rewrite images url in this way. Every image with this path: example.com/john/images/a.jpg Should point to phisical path: example.com/accounts/john/images/a.jpg How can

Mobile browser detection with .htaccess fails with Opera Mini

爱⌒轻易说出口 提交于 2019-12-24 17:39:05
问题 I'm having trouble figuring this one out. I'm trying to direct mobile traffic to the mobile version of a website via HTACCESS User-Agent sniffing, like so: RewriteCond %{HTTP_USER_AGENT} (android|blackberry|ipad|iphone|ipod|iemobile|mini|mobi|palmos|webos|googlebot\-mobile) [NC] RewriteCond %{HTTP_HOST} ^mobile\.mywebsite\.com$ RewriteRule ^([aA0-zZ9\-\/]*)/([^/]*)$ /index.php?page=$1&q=$2&q2=$3&setview=mobile [L,QSA] The string mini|mobi is where the Opera Mini browser should be detected.

Need htaccess redirection

风流意气都作罢 提交于 2019-12-24 17:29:14
问题 I want to redirect below urls using htaccess http://abc.domain.com to http://www.domain.com/pos http://xyz.domain.com/weighing-scales.php to http://www.domain.com/weighing I tried using below directive in .htaccess file but it is not working. Kindly help Redirect 301 http://abc.domain.com http://www.domain.com/pos Redirect 301 http://xyz.domain.com/weighing-scales.php http://www.domain.com/weighing-scales 回答1: You can use the following : RewriteEngine on #--abc.domain.com/ => domain.com/pos--

.htaccess Apache URL Rewrite for Wordpress - permanently pointing one domain to another

房东的猫 提交于 2019-12-24 17:23:46
问题 I am trying to point www.olddomain.com/whatever to www.newdomain.com/whatever (as well as without the www.), but the Wordpress permalinks are not staying intact. Please help!! <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteCond %{HTTP_HOST} ^olddomain.com [nc] RewriteRule ^(.*)$ http://www.newdomain.com/$1 [r=301,nc] RewriteCond %{HTTP_HOST} ^www.olddomain.com [nc] RewriteRule