.htaccess

RewriteCond comparing two variables in Apache htaccess

半城伤御伤魂 提交于 2020-01-05 09:13:07
问题 I would like to have a rewritecond that gets true if two variables HTTP_ORIGIN and HTTP_HOST are equals. I tried RewriteCond %{HTTP:Origin} ^http://%{HTTP_HOST}(/|$) But despite Netbeans syntactic color, it appears that Apache is not replacing %{HTTP_HOST} by its value. I guessed it because RewriteCond %{HTTP:Origin} ^http://cnfr005554(/|$) RewriteCond %{HTTP_HOST} =cnfr005554 Works. So how can I test that the two variables %{HTTP:Origin} and %{HTTP_HOST} are equals? (and yes, it's for

.htaccess works on local server not on main server

拥有回忆 提交于 2020-01-05 08:56:31
问题 I have the following .htaccess file working on the local MAMP server fine. However when I upload it to the main server it can't find the news page. RewriteEngine On RewriteBase / RewriteCond %{THE_REQUEST} \s/+news\.php\?news_id=([^\s&]+) [NC] RewriteRule ^ /news/%1? [R=301,L] RewriteCond %{THE_REQUEST} \s/+Category\.php\?pageNum_RS_Search=([^\s&]+)&totalRows_RS_Search=([^\s&]+)&Category=([^\s&]+) [NC] RewriteRule ^ /Compare/%1/%2/%3? [R=301,L] RewriteCond %{THE_REQUEST} \s/+Category\.php\

Deny access to directory with .htaccess

最后都变了- 提交于 2020-01-05 08:51:59
问题 I want to protect a directory and the php files in it, from direct web access through an .htaccess file like this: IndexIgnore * <Files ~ "\.(php)$"> order allow,deny deny from all </Files> but I want to be able to send ajax requests from a javascript file to those php files an get a result. Is this possible? 回答1: You can only allow POST-requests. Accessing the page from the browser results in an error code, but posting from ajax works. See here. Note: this qualifies as security through

htaccess and php - redirects and pretty urls

亡梦爱人 提交于 2020-01-05 08:51:44
问题 I have a webcommunity, and it's growing now. I like to do a link makeover for my web, and then I need to know the best solution for my case. Right now my htaccess looks kind of like this: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^/\.]+)/?$ index.php?page=user&username=$1 [L] You are able to link to users like this domain.com/username and that's nice. Then I have different pages like index.php?page=forum&id=1 index.php?page

Apache / mod_rewrite / Periods messing with pattern

孤街浪徒 提交于 2020-01-05 08:06:55
问题 First question, here goes nothing... I'm trying to add a new entry to my .htaccess file (Apache server) with the hopes of translating this URL: http://platform.localhost/category.all into this URL: http://platform.localhost/index.php?page=category.all The RewriteRule that I'm currently using is this: RewriteRule ^([^/\.]+)\/?$ index.php?page=$1 This rule has worked fine for all URLs up until now, I can only assume that it is the period that is breaking it. What I'm trying to achieve is having

Apache / mod_rewrite / Periods messing with pattern

冷暖自知 提交于 2020-01-05 08:05:11
问题 First question, here goes nothing... I'm trying to add a new entry to my .htaccess file (Apache server) with the hopes of translating this URL: http://platform.localhost/category.all into this URL: http://platform.localhost/index.php?page=category.all The RewriteRule that I'm currently using is this: RewriteRule ^([^/\.]+)\/?$ index.php?page=$1 This rule has worked fine for all URLs up until now, I can only assume that it is the period that is breaking it. What I'm trying to achieve is having

.htaccess redirect URL to specific pattern

大兔子大兔子 提交于 2020-01-05 08:03:13
问题 Supposing I have some URLs, looking like this: site.com/html/photographers-4.cfm?county=test1 site.com/html/photographers-5.cfm?county=test2&speciality=test3 site.com/html/photographers-9.cfm?address4=test4&county=test5 site.com/html/photographers-10.cfm?county=test6&speciality=test7&address4=test8 where testX (...) may be the same or may differ. How would I be able to rewrite each of these so that the URL will be more eye-catching ? site.com/test1-photographers site.com/test2-tes33

Special characters in mod_rewrite url

只谈情不闲聊 提交于 2020-01-05 07:56:09
问题 I want this URL: http://www.mydomainblabla.com/s/can+you+drill+shrinky+dinks?.html to be rewritten to this one: http://www.mydomainblabla.com/search.php?q=can+you+drill+shrinky+dinks? I am using this mod_rewrite rule in my .htaccess to accomplish this RewriteRule ^s/(.+).html$ search.php?q=$1 [L,QSA] However, the result is not as I want it, when I go to the first url, I get a page not found message. The same problem occurs when I visit this url: http://www.mydomainblabla.com/s/http://www

Redirect all traffic to holding page unless logged in using .htaccess

十年热恋 提交于 2020-01-05 07:43:52
问题 I currently have a landing page setup on my domain.com which already receives traffic. It will shortly be replaced with an online store. I need to upload this store to my live server in order to get it approved by the Merchant Facility Providers (MFP), and they require it to be accessible from it's final live location on domain.com in order to get approvals. I can't have users access this site until it has met approvals. To accomplish this I wish to redirect all domain.com traffic to domain

How to write a htaccess file to wildcard folder to subdomain

半腔热情 提交于 2020-01-05 07:42:30
问题 I'm trying to redirect all my folders (using a wildcard) to their subdomain. For example: www.mywebsite.com/folder1 to folder1.mywebsite.com/ www.mywebsite.com/folder2 to folder2.mywebsite.com/ www.mywebsite.com/folder3 to folder3.mywebsite.com/ Now without writing a rule for each one of them, is there a way to redirect them all to their respective subdomain? I tried: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com$ RewriteCond %{HTTP_HOST} ^(\w+)\.mywebsite\.com$ RewriteRule