.htaccess

How to use a RELATIVE path with AuthUserFile in htaccess?

故事扮演 提交于 2020-06-09 08:06:11
问题 I have a .htaccess that uses basic authentication. It seems the path to the .htpasswd file isn't relative to the htaccess file, but instead to the server config. So even though I have the .htaccess and .htpasswd files in the same directory, this doesn't work: AuthType Basic AuthName "Private Login" AuthUserFile .htpasswd Require valid-user However, it does work if I change the AuthUserFile to use the absolute path: AuthType Basic AuthName "Private Login" AuthUserFile "/home/user/public_html

mod_rewrite with ? in the original URL like YouTube

蹲街弑〆低调 提交于 2020-06-01 03:41:55
问题 Ok I want to simulate the YouTube URL and redirect it to my real URL. Reason being is I used a random string to make video ID's so they aren't guessable by sequence. I have the links as so http://www.mysite.com/watch?v=Dxdotx3iT1 and want to redirect to http://www.mysite.com/index.php?page=videos&section=view&v=Dxdotx3iT1 Can't seem to figure out the mod rewrite. Also using a ? I believe tells it to do something. Any help would be appreciated. 回答1: You need to adjust your RewriteRule to

How do you write an htaccess RewriteRule to make my urls work like youtube?

家住魔仙堡 提交于 2020-05-28 12:05:33
问题 I have a php file called index.php, in this file I have a php variable $video which receives its information from a $_GET["v"] request. If I use https://www.example.com/index.php?page=video&v=UnIq3Id I can fill the $video variable. When I write a RewriteRule, which I have tried; #FIRST RULE TRIED RewriteRule ^watch$ index.php?page=video [QSA] #SECOND RULE TRIED RewriteCond %{QUERY_STRING} ^v=(.+) RewriteRule ^watch /index\.php?page=video&v=%1 [QSA,R=301,L] I got these rules from mod_rewrite

CodeIgniter removing index.php from url

放肆的年华 提交于 2020-05-24 07:30:08
问题 My current urls look like this [mysite]index.php/[rest of the slug] . I want to strip index.php from these urls. mod_rewrite is enabled on my apache2 server. In config , $config['index_page'] = ''; My codeignitor root .htaccess file contains, RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L] But still it is not working. Where am I going wrong? 回答1: Try the following Open config.php and do following replaces $config[

Applying basic auth to certain parameter

巧了我就是萌 提交于 2020-05-17 06:46:09
问题 I want to protect an access that contains certain parameter using basic auth in .htaccess file. For example, I want to require Basic Auth for an access to /test.html?protected=yes and allow access to /test.html?protected=no without basic auth. Is this possible? 来源: https://stackoverflow.com/questions/61219950/applying-basic-auth-to-certain-parameter

url routing with PHP and .htaccess

五迷三道 提交于 2020-05-17 06:01:24
问题 I want to use the MVC pattern to divide my logic, from the presentation and the data. Well, i've been searching for i while. But the truth is that i don't even know what to search. I'm trying to setup a MVC Framework in php. I'm following a tutorial on youtube, and i'm stuck at the routing point. I've read a LOT of guides, and every single one teaches things in different ways, creating only more confusion. The point is this: i have a .htaccess file that contains some directives (but the

htaccess howto rewrite an encoded slash in url

空扰寡人 提交于 2020-05-16 13:55:52
问题 I have URL with an encoded slash ( %2F ) and I cannot get rewrite rules to catch this correctly. My URL is: http://example.com/some-path/description%2Frest-of-description/1101 I've tried rewrites like:- # is the %2F interpreted as a path separator RewriteRule ^some-path/(.*)/(.*)/(.*)$ /property/view?ref=$3 [B,R=301,L] # or is it as an encoded string RewriteRule ^some-path/(.*)%2F(.*)/(.*)$ /property/view?ref=$3 [B,R=301,L] # or even double encoded RewriteRule ^some-path/(.*)%252F(.*)/(.*)$

.htaccess AuthUserFile variable based on environment

天大地大妈咪最大 提交于 2020-05-15 09:34:09
问题 I'm trying to load the .htpasswd file based on environment. If I hard code the URL it works fine. AuthType Basic AuthName "Password Protected" AuthUserFile /var/www/html/sitename.dev/docroot/.htpasswd Require valid-user Our hosting provider is providing a global variable you can use in htaccess. %{ENV:AH_SITE_ENVIRONMENT} The Acquia hosting environment — possible values are dev , test , or prod Using the variable we can check on which environment we currently are. If needed it can also be

Use .htaccess to set 404 error document located in the same folder

北慕城南 提交于 2020-05-14 19:04:38
问题 So... i am trying to set the path to an error document located in the same directory as the .htaccess (located in the WEBSITE "root") like this: ErrorDocument 404 404.php However instead of showing the webpage...it just writes 404.php on the screen. I can't use absolute paths like: ErrorDocument 404 /404.php Because i am not doing the website for me and i do not know the absolute path of the folder the website will be stored on... My question is: Can i set relative paths in the .htaccess

.htaccess Messing up with .php extension?

非 Y 不嫁゛ 提交于 2020-05-09 06:08:09
问题 Ok, so I have this mod_rewrite rule that internally attaches a .html extension if it is not provided when sending the request: Options +FollowSymLinks RewriteEngine on # ## Internally rewrite extensionless file requests to .html files ## # # If the requested URI does not contain a period in the final path-part RewriteCond %{REQUEST_URI} !(\.[^./]+)$ # and if it does not exist as a directory RewriteCond %{REQUEST_FILENAME} !-d # and if it does not exist as a file RewriteCond %{REQUEST_FILENAME