Posts

Showing posts from March, 2022

Apache: keep track of non-404 errors (e.g., 403, 500, et al)

Apache: keep track of non-404 errors (e.g., 403, 500, et al) - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about php, htaccess, , , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : In cpanel I always have the error log open ("This function will display the last 300 errors for your site.") which is nice for 404's but what about the rest? I'm working on a few things in htaccess, such as this: RedirectMatch 403 /($|*)/?$ So now when I try any URL with a dollar-sign or an asterisk in it, bam, 403 forbidden; perfect. S...

htacess seems to make the page load forever

htacess seems to make the page load forever - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about web-hosting, php, htaccess, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I need to rewrite a URL of my server so the URL looks friendly. Like: site.com/var1/var2/var3/... to site.com/index.php?page=var1/var2/var3/... So I wrote this .htacess: RewriteEngine On RewriteRule ^.*$ index.php?page=$1 [NC,L] But when I upload it to the server, and try to load a page, the page loads forever! What am I doing wrong? Solution : RewriteRule ...

Inserting WordPress in a site with .htaccess Rewrite Rule

Inserting WordPress in a site with .htaccess Rewrite Rule - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about php, htaccess, web-development, wordpress, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I want to insert a WordPress blog in a website which is programmed in PHP and that uses includes() to select what content to show, and that uses .htaccess Rewrite Rule to get friendly URLs. The problem is that when installing WordPress in a subdirectory the rewriteRule executes and doesn't let the user get to the subdirectory wher...

Is there an API or programmatic way to convert ".htaccess" rewrites to "web.config" IIS Rewrites?

Is there an API or programmatic way to convert ".htaccess" rewrites to "web.config" IIS Rewrites? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, iis, url-rewriting, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I know I can do it in IIS Manager, but I am looking for some programmatic way to do it. We need to do this for customer all the time. So it would be great if there's a programmatic way of doing so. Solution : There isn't a reliable programmatic way to automatically convert ...

Switch to https

Switch to https - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about apache, htaccess, mod-rewrite, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I'm looking to use an .htaccess file to use mod_rewrite to switch the protocol from http:// to https:// when someone hits my website. For instance, once someone goes to: http://www.mywebsite.com/ I'd like the browser to switch to: https://www.mywebsite.com/ The same goes for the http://mywebsite.com/ -> https://mywebsite.com This is the following code I've been using an...

Link to pages on site without .html extension appearing in browser?

Link to pages on site without .html extension appearing in browser? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, url, mod-rewrite, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I've modified my .htaccess file to allow access to html files without having to include the extension on the end, for example: www.mysite.com/document directs to www.mysite.com/document.html However, when I want to link to pages within my site using something like <a href="page.html"></a> I still get t...

Htaccess RewriteCond based on environment variable

Htaccess RewriteCond based on environment variable - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, apache, mod-rewrite, custom-variables, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I find apache very unfriendly. Anyway. I have this: RewriteRule (.*) - [QSA,E=DOMAIN_NAME:localhost.com] This doesn't redirect, which is fine: RewriteCond "www.%ENV:DOMAIN_NAME" "!=www.localhost.com" RewriteRule ^ https://%HTTP_HOST?err=%ENV:DOMAIN_NAME [L,R=301] This doesn't redirect, which is fine: Rewrite...

htaccess redirect non-www to www with SSL/HTTPS

htaccess redirect non-www to www with SSL/HTTPS - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, apache, https, mod-rewrite, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I want a rewrite rule that redirects everything to https:// AND www . For example http://example.com should be going to https://www.example.com This is what I have: RewriteEngine On RewriteCond %SERVER_PORT !=443 RewriteCond %HTTP_HOST ^(www.)?example.com$ [NC] RewriteRule ^(.*)$ "https://www.example.com/$1" [R=301,L] Solution : I f...

404 not found errors when using Modx CMS in a subfolder

404 not found errors when using Modx CMS in a subfolder - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about seo, htaccess, apache, modx, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I have installed Modx CMS on my hosting provider, but instead of installing it on my root directory where it usually goes, I put it in a folder on the root directory called makeabio. directory loads fine but when I click on a link in my page it would take me to the index.php file located outside the folder in the main directory. I believe it has some...

Non-existent subdirectories of index.php do not return "404 not found"

Non-existent subdirectories of index.php do not return "404 not found" - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, url, 404, subdirectory, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : My website usually correctly returns 404 not found errors if I enter names of documents or folders that do not exist. However, I have recently noticed something strange. The homepage of my website is called index.php and does not have any subdirectories because it is simply a file and I do not use a CMS. But when I ent...

addon domains keeps adding primary domain in URL

addon domains keeps adding primary domain in URL - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about linux, htaccess, dns, cpanel, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I took new vps plan from inmotionhosting.com and moved my host from previous hosting company. I have several cpanel accounts in the whm, imported them all using the migration tool from server to server. After many attempts, only primary domain from each account works ok, any addon domain in any cpanel account adds the of the primary add in the URL when vis...

.htaccess Rewrite whole dir contents to another

.htaccess Rewrite whole dir contents to another - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, url-rewriting, nginx, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I am trying to rewrite the whole contents of a directory to the home url. so, if someone visits www.example.com/bnn27sh32j@d299/gold it should take them to www.example.com/gold I have tried: RewriteRule ^bnn27sh32j@d299/(.*)$ /$1 [R=301,NC,L] doesnt work, maybe its because it has the illegal characters in the dir name? Solution : Try this: Redirec...

How to track usage of redirecting domains using either Google Analytics or server logs using Apache

How to track usage of redirecting domains using either Google Analytics or server logs using Apache - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about , , , , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : My company utilizes numerous domains and TLDs that all end up pointing to one main domain. The domains include variations of the company name or its product items. For instance, domain.cc, domain.biz, domain.info, do-main.cc, do-main.biz, do-main.info , etc. As the webmaster, I am tasked with tracking these domains and their us...

How to require user login using htpasswd within the htaccess file?

How to require user login using htpasswd within the htaccess file? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about web-hosting, htaccess, web-development, security, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I'm trying to require users to login and would like to handle the request with htpasswd in the htaccess file: Any ideas on how I can do that? Solution : You can do this using the .htpasswd method via .htaccess file. You can see how to use it here : Password Protection with htaccess With .htaccess it is ...

IP-based redirection using mod_rewrite

IP-based redirection using mod_rewrite - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, mod-rewrite, apache2, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I'm running a small VPN server where each user has his own static IP. I set up an Apache server in order to host files for each of them and instead of using a new registration system, I wanted to take advantage of those static IPs. So I thought I could use mod_rewrite to achieve that and wrote this snippet: RewriteEngine On RewriteBase / RewriteCon...

Rewrite in Mediawiki, remove index.php, .htaccess

Rewrite in Mediawiki, remove index.php, .htaccess - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about apache, htaccess, redirects, 301-redirect, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I've just installed Mediawiki on Apache and I want the URL should be: localhost/Main_Page/ localhost/Special:Recent_Changes ... instead of: localhost/index.php/Main_Page/ localhost/index.php/Special:Recent_Changes I've tried many times and in many ways but it still doesn't work. Any suggest for a "exactly" what to do, st...

Require domain alias to show in browser address bar

Require domain alias to show in browser address bar - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about domains, htaccess, apache, redirects, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : Similar to question posted here (but not related to sub directories): .htaccess redirect of domain name alias to main domain but must show up as the alias domain I am trying to direct traffic from an alias domain I have to my site that is on the same server, while also keeping the alias domain in the browser address bar. This is my original hta...

Is it a good practice to block spam bots by IP ranges?

Is it a good practice to block spam bots by IP ranges? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, web-crawlers, robots.txt, spam, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I'm getting too many hits on my website from Yandex. It doesn't obey robots.txt and by some way it can bypass .htaccess rules. So I'm thinking to block all Yandex IP ranges in my system firewall. Is that a good way that won't block legit users/traffic as well? What are the downsides for such action? Solution : I...

combined 301 redirects not working

combined 301 redirects not working - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, 301-redirect, mod-rewrite, user-friendly, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I made some changes to the files on a website and now Search Console is showing me 404 errors for some URLs. The normal setup, which works fine is like this: the user-friendly URL mywebsite.com/modeles-voiture/Volvo/XC60 is rewritten to get to the PHP script as: RewriteCond %REQUEST_URI ^/?modeles-voiture [NC] RewriteCond %REQUEST_FILENAME !-f ...

Redirect loop from two domain using the same .htaccess

Redirect loop from two domain using the same .htaccess - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, redirects, 301-redirect, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : How our FTP was setup, the root level is Website #1. Website #2 has it's own directory folder inside that root. Both websites refer to the same .htaccess . If I do Redirect 301 /example/ http://www.website2.com/example/ , there will be a redirect loop. It will redirect http://www.website1.com/example/ to http://www.website2.com/example/ ...

How to remove trailing slashes from URL with .htaccess in localhost?

How to remove trailing slashes from URL with .htaccess in localhost? - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, mod-rewrite, trailing-slash, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : Here is my localhost folder structure: •www (wamphost folder) •example.com (folder) •index.php With the current the URL results: localhost/example.com/ The URL I would like is: localhost/example.com What I would like: My intention is remove the slash beside URL, but I tried so many ways and still no clue how. I am...

Which method is better to add "www." before domain name

Which method is better to add "www." before domain name - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, url, url-rewriting, cname, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I have search through Google and found 2 methods to add www before domain name. First is by adding a CNAME and second is using rewrite mod in .htaccess file. I just want to know which method is better to use or there is other method because I'm currently using standalone WordPress as my back end. Solution : You need both -...

.htaccess wreaking havoc on site root! Help!

.htaccess wreaking havoc on site root! Help! - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, directory, subdirectory, , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I was taught that it is a good practice to separate publicly viewed webpages from included files and other, more sensitive information. That poses a problem, however, when you wish to request index.php in the public folder. Allow me to illustrate: Site Root/ Includes/ -server_side_validation.php Public/ -index.php JS/ ...

Restrict access to certain files but not when linked from my own website

Restrict access to certain files but not when linked from my own website - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, referrer, , , .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : I got a problem regarding setting my server settings so that my files can't be accessed from people linking directly to the files, but can when they click a link on my website to open the file. I tried this: RewriteCond %HTTP_REFERER !^http://19.24.3.13/~child/ [NC] RewriteCond %HTTP_REFERER !^http://19.24.3.13/~child/.*$ [NC] Rewrite...

URL is generating a /#!/splash-page

URL is generating a /#!/splash-page - .htaccess  files are  extremely useful  in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug  .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about seo, htaccess, web-development, url-rewriting, .htaccess  common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your  .htaccess file running smoothly. Problem : My site for some reason is generating a shebang - /#!/splash-page on the URL. For example when I type www.modernvintage1005.com , the browser returns www.modernvintage1005.com/#!/splash-page and every subsequent page is /#!/about , /#!/contact , and so forth. There's absolutely nothing on the Google about this. There is a lot of rewrite help to e...