.htaccess

How to deny access to specific pages with htaccess

∥☆過路亽.° 提交于 2021-01-28 07:38:09
问题 How can I send a 404 page error for specific pages that exist on the web server? (Using htaccess). For example, I have a config.php file and when I go to localhost/config.php it just shows a blank white page with nothing in it. I want it to appear as a 404 page, like the page doesn't exist. How can I do that? Thanks! 回答1: If you specifically want to return a 404 Not Found then you can use mod_rewrite, near the top of your .htaccess file: RewriteEngine On RewriteRule ^config\.php$ - [R=404,L]

htaccess Rewrite Rules appending parameter?

巧了我就是萌 提交于 2021-01-28 07:05:04
问题 Our original urls began with a parameter and the following rewrite works to redirect them (thanks to Jon Lin). However, the original parameter is being appended to redirect, so that RewriteEngine On RewriteCond %{QUERY_STRING} ^old-page$ RewriteRule ^$ /newpage [R=301,L] ends up going to mydomain.com/newpage?old-page Any idea how to fix? thanks again, Geoff 回答1: Have it like this to strip off existing query string: RewriteEngine On RewriteCond %{QUERY_STRING} ^old-page$ [NC] RewriteRule ^$

stop requests for index.php+++++++++

眉间皱痕 提交于 2021-01-28 06:47:14
问题 I am trying to redirect users requesting a root index.php I was using Redirect 301 /index.php http://mywebsite/junk/index.html while this works ok IF people only request index.php, but now i am getting many requests for index.php++++ (sometimes more ++ than others) is there something I can add to Redirect 301 /index.php to include redirecting index.php+++ ? 回答1: You can use mod_rewrite for regex capabilities and finer control: RewriteEngine On RewriteRule ^index\.php http://mywebsite/junk

Htaccess directory with parameter to url parameters

﹥>﹥吖頭↗ 提交于 2021-01-28 05:53:49
问题 I have a url domain/p1/p2/p3/?order=p4 I would like to convert this into all parameter using htaccess like: domain?var1=p1&var2=p2&var3=p3&order=p4 This is what I'm using right now: RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/\order=[A-Za-z]?$ page.php?var1=$1&var2=$2&var3=$3&order=$4 [NC,L] 回答1: You don't need to match query parameter ?order=p4 here and you will need QSA flag: RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)/?$ page.php?var1=$1&var2=$2&var3=$3 [QSA,L] 来源: https://stackoverflow.com

Cannot remove index.php from urls using Codeigniter on MAC OSX

微笑、不失礼 提交于 2021-01-28 05:47:50
问题 I just bought a Mac-pro with Mavericks 10.9.1 and before that I was working on pc with Windows 7. I created a project under the windows 7 OS and now I want to import it to OSX, the import was successful apart from the .htaccess file. I can't remove index.php from my urls. I have MAMP installed and my urls only work if I use index.php : don't work : (localhost/~username/feel/products) work : (localhost/~username/feel/index.php/products) I tried all the options of RewriteEngine, RewriteCond and

Angular 8 / Apache: htaccess for root and sudomain app

∥☆過路亽.° 提交于 2021-01-28 05:45:10
问题 I have 2 Angular apps, each of which runs fine in the root directory of a domain of an Apache webserver (hoster). Now I like to place them into App1 => https://example.com App2 => https://app2.example.com "app2" subdomain folder is "/app2" from root directory. If I put App2 into the subdomain directory both still run, but App2 only as long as I don't do a refresh of the page (I get a 404 not found). I did some search but most examples focus on subdirectories not subdomains, I tried to use ng

htaccess change url parameter

冷暖自知 提交于 2021-01-28 05:39:07
问题 I have a WP site which uses a calendaring plugin - currently the url the calendar system creates to change the month view of the calendar is hitting a url which fails to advance the month view of the calendar... I have worked out what the correct url should be - but need a way of redirecting from the incorrect url to the correct one... So... The incorrect url is: /calendar/?date=2018-04 The correct url is /calendar/?tribe-bar-date=2018-04 So, I am basically looking for a way to redirect /

How to set codeigniter for apache server?

試著忘記壹切 提交于 2021-01-28 05:10:10
问题 Updated , I'm having some issues with deploying codeigniter project on Ubuntu server, i get 404 Apache error when i click on links. When i put the project in http://roy.my-domain.com/ = /var/www/html/ folder - it's all works fine - but when i added sub directory http://roy.my-domain.com/roy/ = /var/www/html/roy/ - i get 404 errors . When my url is http://roy.my-domain.com/roy/index.php/about - i get codeigniter 404 error and not apache2. The error : Not Found The requested URL /index.php was

htaccess wordpress rewriterule not working 404 error

霸气de小男生 提交于 2021-01-28 04:51:28
问题 I'm attempting to make a rewriterule for a page to load the content of another one and show the proper information. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^index\.php/file/(.*)$ index.php/file/?value=$1 [L,QSA] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> When i put my url it shows me a 404 error

If is not localhost statement htaccess

岁酱吖の 提交于 2021-01-28 03:56:13
问题 i'm currently forcing visitors to access all my websites (mostly Wordpress) over https, witch i do with the following code: RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L] Now i was wondering if i can use an if is not statement, so if i work on my local environment, this won't work. For example: <If "%{HTTP_HOST} != 'http://localhost:8888'"> # live configuration </If> <Else> # local configuration </Else> What's the best way to do this?