mod-rewrite

Allow access in htaccess based on the HTTP:X-FORWARDED-FOR

谁都会走 提交于 2019-12-24 03:39:11
问题 Hi i should only allow the particular ip address(which is HTTP:X-FORWARDED-FOR adresses) to access the files. I have done it by the following Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP:X-FORWARDED-FOR} !^xxx.xxx.x.xx$ RewriteRule ^$ http://xxx.xxx.x.xx/access_denie.php [R=301,L] Now i have to allow it for multiple ip for example yyy.yy.y.yy. How can i do it by using htaccess 回答1: The ^xxx.xxx.x.xx$ portion of your RewriteCond is simply a regular expression. You

how do i show 404 error page without showing the error page's url?

一个人想着一个人 提交于 2019-12-24 03:32:37
问题 when my users type a non-existent page such as www.example.com\wrongurl.html I want users to see 404 error page. But the URL should not change. I have tried the following but doesn't work. ErrorDocument 404 http://www.example.com/404.html RewriteEngine On RewriteRule 404/ http://www.example/404.html [NC] How can i do this? 回答1: Try the following rules : RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ /404.html [L,NC] This internally

Use htaccess to mask domain and folder name

大城市里の小女人 提交于 2019-12-24 03:03:16
问题 I'm trying to use htaccess and mod_rewrite to mask one domain and two of its sub-folders with another domain. For example: http://example.com/sub/sub-sub/ to http://example-2.com/ So that http://example-2.com/ is what shows in the browser address bar, but the content of http://example.com/sub/sub-sub/ is what's displaying on the page. I found this question/answer which should accomplish this, but it doesn't work when I implement it. Current htaccess: Options +FollowSymlinks RewriteEngine On

redirect to another domain, but keep the url [duplicate]

纵饮孤独 提交于 2019-12-24 02:54:08
问题 This question already has answers here : Redirect to other domain but keep typed domain (2 answers) Closed 2 years ago . I have 2 vhosts: www.example1.com and www.example2.com I have a page on www.example1.com/page.html I want this page to be accessible in the other domain, meaning I want people to be able to get to www.example2.com/page.html and view that page that is physically on the other vhost. But the URL must display www.example2.com I don't want to simply move the page physically to

htaccess Rewrite URL Without .php Extension To File

匆匆过客 提交于 2019-12-24 02:44:10
问题 I got a website that using osCommerce which all the page can be access directly with http://www.example.com/pagename.php , but now I would like to tweak the htaccess file so that it can supports http://www.example.com/username and then redirecting to http://www.example.com/account.php?id=username , while other pages still can be access using the same old way. It means that if the htaccess detect that the URL didn't have any extension, then it will be redirecting to http://www.example.com

.htaccess Redirect subdomain to domain

心已入冬 提交于 2019-12-24 02:33:47
问题 I got a subdomain http://sub.domain.com I want all links from this subdomain be redirected to a target domain with www, nonwww and also redirect the path. REDIRECT: www = http://www.sub.domain.com nonWww = http://sub.domain.com path = http://sub.domain.com/something/anything to TARGET: http://www.domain.com/sub/zero What is the .htaccess for this? What would be the change if i don't want to transport the path to the new target, so have a static target? 回答1: Put this code in your DOCUMENT_ROOT

Manual content compression in Apache

岁酱吖の 提交于 2019-12-24 02:16:57
问题 I need a manual compression solution on Apache. My goals: Provide gzip-encoded content on my server along with uncompressed. Files are pre-compressed. Not all files are served compressed. I want to specify these files and the choice isn't type (extension) based. Many content-types (custom ones) are served, and new types are showing up from time to time. Also, file extension doesn't determine if it will be compressed or not ( !!! ). Keep overhead minimal (the less extra headers, the better).

mod_rewrite replace '_' with '-'

此生再无相见时 提交于 2019-12-24 02:11:17
问题 I'm almost there with a mod_rewrite rule, but I've caved in :) I need to rewrite country/[countryname].php to country/[countryname]/ however, [countryname] may have an underscore like this: 'south_africa.php' and if it does I want to replace it with a hypen: 'south-africa/' I also want to match if the country has numbers following it: 'france03.php' to 'france/' Heres my rule, its almost there but its still adding a hyphen even if there is no second part after the underscore. RewriteRule

mod-rewrite rule for sitemap.xml

六月ゝ 毕业季﹏ 提交于 2019-12-24 02:08:31
问题 I am using a CMS that hosts multiple websites simultaneously and I am seeking a method to properly serve sitemap.xml files for each site. I have concluded that a mod-rewrite rule will be the most effective solution for this. My idea is to have a /sitemaps/ directory with the site map for each domain named as the domain name, i.e. /sitemaps/acmewidgets.com.xml Since the appropriate sitemap url would be acmewidgets.com/sitemap.xml I need assistance with creating a mod-rewrite rule that will map

Mod_rewrite: Include query string when redirecting

十年热恋 提交于 2019-12-24 01:47:08
问题 I've got a small problem with mod_rewrite. This is my code: RewriteEngine on RewriteRule ^(.*)$ http://newsite.com/moved.php?q=$1 [R=301,L] This almost works, if I go to oldsite.com/apage.php, I get redirected to newsite.com/moved.php?q=apage.php. However, if I go to oldsite.com/apage.php?var=15, I get redirected to newsite.com/moved.php?q=apage.php again. How could I make oldsite.com/apage.php?var=15 redirect to newsite.com/moved.php?q=apage.php?var=15 Thanks a lot! 回答1: Use the QSA flag to