.htaccess

Redirect internal to path, if resource doesn't exists

馋奶兔 提交于 2020-01-03 03:39:12
问题 i am trying to redirect internally to another location, so the user won't see the "script" location / uri, if an image does not exists: RewriteCond %{REQUEST_URI} ^/resources/img/tires [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^resources/img/tires/(.*)$ reifen/imagematch/$1 [L] For example if i request an image: http://domain.tld/resources/img/tires/manufacturer/image.jpg -> Image exists, directly serve the image. And if i request: http://domain.tld/resources/img/tires

301 redirection of all pages except the homepage

送分小仙女□ 提交于 2020-01-03 03:34:10
问题 What I'm trying to achieve is a 301 redirection of all the pages/resources for a domain except the root of the site every page then should move from www.example.com/example.com to old.example.com. I'm not an htaccess guru but this is the solution I came up with... RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteCond !^$ [NC] RewriteRule ^(.*)$ http://old.example.com/$1 [R=301,L] But seems not to work 回答1: You were missing the TestString in the RewriteCond RewriteEngine On RewriteBase

How to redirect site to https and http using htaccess for specific file and folder

喜夏-厌秋 提交于 2020-01-03 03:31:10
问题 I have a wordpress site that I wanna change https to http for only '/wp-admin' and 'wp-login.php'. I wanna use .htaccess to achieve it, but I m not good at regular expressions. Below is my current htaccess codes. # Force HTTPS for /my RewriteCond %{HTTPS} !=on RewriteCond %{THE_REQUEST} !^[A-Z]+\s/wp-admin [NC] RewriteRule !^wp-admin https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L] # Force HTTP for anything which isn't /my RewriteCond %{HTTPS} =on RewriteCond %{THE_REQUEST} ^[A-Z]+\s/wp-admin

Redirecting folder from one domain to another using .htaccess 301 redirect

别说谁变了你拦得住时间么 提交于 2020-01-03 03:26:09
问题 I'm trying to figure out a rewrite so as to redirect a directory and all of it's files & subdirectories from one domain to another. Here is what I would like to achieve: olddomain.com/oldfolder/* to http://newdomain.com/newfolder/* Currently I am using the following: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$ RewriteRule (.*) http://newdomain.com/newfolder/$1 [L,R=301] This works for www.olddomain.com but not also for olddomain.com. What's the best way to

Subdomain disallow search bots via robots.txt

可紊 提交于 2020-01-03 03:19:04
问题 I want to disallow search robots to access the entire domain including subdomains using Robots.txt and potentially .htaccess I want to make sure that any new subdomains in future are blocked without having to create one in the root of subdomain every time. Is this possible? 回答1: If you want to block robots via robots.txt, you'll have to create one for each subdomain. I suggest a script that monitors your Zone File and then automatically creates one. Another solution is to use HTTP Basic Auth.

Block Range of IPs

橙三吉。 提交于 2020-01-03 03:17:06
问题 I'm trying to block a range of IPs from visiting my website Here is what I have in my .htaccess file order allow,deny Deny from 64.244.0.0/64.245.255.255 Deny from 64.244.0.0/15 allow from all I'd like to know if anyone can tell (or estimate) me how many IPs have i blocked there? 回答1: I believe the first DENY FROM is just wrong. I've always seen it this way 64.244.0.0/15 Base Address^ ^Number of bits to use for subnet This would mean that you have 2^15 addresses in the deny block. Edit Using

.htaccess redirect/rewrite help needed

徘徊边缘 提交于 2020-01-03 03:13:11
问题 I am writing htacess redirect rule but it is not working properly I have tried many solutions but simply it is not working. What I want to do is to I have url http://example.com/cms/index.php?page=filename I want this url to be executed and show appropriate page but in browser it should show example.com/cms. And what is important is I only want to right this rule for this page only and it should not effect to other pages. Thank you. 回答1: RewriteRule ^([^/]+)/$ /cms/index.php?filename=$1 [L

SEO Friendly URL to Dynamic Arabic Category URL using PHP

空扰寡人 提交于 2020-01-03 03:11:08
问题 Currently I have a url like this domain/index.php?cat=مال_وأعمال I want to set things up so that our Marketing people can publish url's like domain/مال_وأعمال I've tried several solutions including: mod_rewrite - the problem with this approach is that it becomes a huge .htaccess file since we need to write a rule for each category. RewriteMap - this came pretty close since I could query the database to build map file for output. However, I've since learned we don't have access to httpd.conf.

.htaccess remove trailing slash after file extension

心不动则不痛 提交于 2020-01-03 03:05:12
问题 I have some external links to my site that referrer to pages with a file extension and a trailing slash after that e.g. http://example.com/folder/page.php/ I can not change these links, but I would like to 301 redirect those links to this format instead: http://example.com/folder/page/ I've tried this, but it doesn't work: RewriteRule ^(.*)\.php\/$ /$1/ [R=301,L] Any help is appreciated. 回答1: Try this in your /.htaccess file RewriteEngine On RewriteCond %{THE_REQUEST} /([^.]+)\.php/? [NC]

.htaccess Rewrite Within Directory - Hide PHP extension and force trailing slash

回眸只為那壹抹淺笑 提交于 2020-01-03 02:56:08
问题 I'm trying to hide the .php extension from my files as well as force a trailing slash on the resulting URLs. Example: A request to /about.php would become /about/ and requests to /about would go to /about/. The following rewrite code worked perfectly when I was in the root of my hostdomain: RewriteEngine On RewriteRule ^(.*)/$ /$1.php [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*)$ http://edit.mydomain.org/$1/ [R=301,L] RewriteCond %{THE_REQUEST}