mod_rewirte (.htaccess) strange behavior for URLs having ".profile" text - php

I got a hosting with WordPress engine installed and inside the root of WP engine folders I've created another web application which is having problems with URLs containing .profile word. When this text is added to URL I'm always receiving 404 error.
Here's an example:
WordPress blog URL: https://mainsite.com
Sub web application folder name: webapp
Sub web application access URL: https://mainsite.com/webapp/
So, when I try to access URL like this: https://mainsite.com/webapp/login.php?code=user.profile I'm receiving error 404. At the same time URL like this: https://mainsite.com/webapp/login.php?code=user.profilb is working fine (2nd URL got last letter replaced by another symbol).
I think this is an issue with WordPress default mod_rewrite settings, here they are:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I got no clue at all why this could happen with .htaccess file like this. Could you suggest please?

It turned out that the issue was with mod_security of a2hosting. They were blocking all sensitive linux files and folders, like: .profile, .htaccess, .bashrc...
Hope, this will help someone.

Related

Moving wordpress site from hosting to localhost for development

After moving website to my local dev machine, relative links stopped working. When i click button with relative link /login, for example, browser redirects to
https://localhost/login/
and shows
Code: Not Found
The requested URL /index.php was not found on this server.
While it should have redirected to https://localhost/сс/login/
.htaccess contents on localhost:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /cc/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /cc/index.php [L]
</IfModule>
Website files are in var/lib/html/cc folder.
SiteURL and HomeUrl
are both equal to http://localhost/сс
Parmalinks setting http://localhost/cc/sample-post/ is used, so no problem with navigating to pages.
How to fix this issue?
Tried different .htaccess modifications, moving index.php to /var/lib
Nothing helps.
just use WP Migrate DB plugin for database export , it will change all link to your desire link and use this database export file in live site
Link ( https://wordpress.org/plugins/wp-migrate-db/)

Why isnt localhost loading all the correct resources of my wordpress application?

I am trying to copy down my web app from the internet to localhost on my machine for further development. The URL of my project is www.uniformlab.net. I am new to wordpress and this site is the biggest one that I have tried to copy.
I am using MAMP as my local server and have set up all the correct variables in getting the database set up. Some resources are loading and many are not, with a large download time.
This is a list of errors that are being thrown on runtime of the website. I don't think that these resources are being called from an absolute path.
I have set the home and siteurl settings in the DB to locahost:80/UNIFORMLAB
When I change the url to localhost/uniformlab/wp-admin, I am getting thrown ERR_TOO_MANY_REDIRECTS by the browser.
I have checked my htaccess file and it seems normal. This is what I have:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Any help would be appreciated.
There is not too much info, but one thing is that the home and siteurl in WordPress have to be the full path to the WordPress directory.
You said that your URL is http://localhost/uniformlab but you changed the setting to localhost
Update again the home and siteurl to http://localhost/uniformlab

HTML: ZIP file download from server issue

I'm sorry about my tittle. I'm not sure how I can categorize this question.Please do edit if necessary-Thanks
Here is the issue I'm having:
http://domain.com is my main server- in this main server I'm listing all of the downloadable files I have from another server which is http://myfilehost.com.
on http://domain.com I list my files like so:
download myfile document
download all myfile
The first link is working perfectly fine but when it comes to the zip file I always get the ff error which is really weird:
Here is the htaccess of http://myfilehost.com which I think is the default of wp as its also a wp website not sure if this is hosted on hostgator/bluehost:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
And o I think this is also worth mentioning:
When I try to go to http://myfilehost.com first and wait for it to load then add the directory /downloads/myfile.zip to the URL its actually working perfectly and downloading myfile.zip..
Thank you Everyone for your kindness of helping me and giving me a response

.htaccess redirect from Wordpress URL to Normal site URL

I have rebuild a site. The old site was WordPress and new site is normal php site with same amount of pages.
I do not want to lose the outside plus google links to this pages and need to do a redirect in .htaccess
I know how to do this with normal links e.g. www.domain1.com/guesthouse.html to www.domain2.com/guesthouse.php
I do not understand the wordpress link with no ".php or .html" at the end of the link.
The old link is www.doamin.com/guesthouse/ (only this without .html or .php)
New link must be www.domain.com/gusethouse.php
The WordPress .htaccess file looks like this
`# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress`
Can I delete the above code and replace with
`Redirect 301 /guesthouse/ http://www.domain.com/guesthouse.php`
or must I add it to the existing .htaccess code.
Do not know how to do it right, please help.
Thank you.
The .htaccess file will execute prior to your PHP interpreting engine running. This means that you're higher in the execution chain than the Wordpress software.
If you're not going to use your Wordpress website anymore, then there's no reason to send requests to it!
Instead, just simply remove all of that code, and rewrite the URL's accordingly.

PHP file in WordPress Directory

I have created a folder within WordPress public_html folder and created a test.php file in it as below.
www.mysite.com/myfolder/test.php
When I navigate to this url, I get page not found 404 error. All other files in myfolder, e.g. test.txt load without any issues. It's just php files that are not running. Could anyone please help?
My .htaccess file is
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
WordPress has its own .htaccess that is probably treating your URI as some sort of "Search Engine Friendly" thing, and translating it into some other format that WP is expecting. For example, http://www.mysite.com/myfolder/test.php might get rewritten to something like http://www.mysite.com/myfolder/index.php?target=test%25php. That would give a 404 error from within WP (not a real server 404 error). Perhaps something can be done from within WP's configuration, or you could modify the .htaccess to tell it specifically not to rewrite test.php.
This is weird since WP leaves your files alone due to RewriteCond %{REQUEST_FILENAME} !-f condition.
Try creating a myfolder/.htaccess file with this line:
# just one line here
RewriteEngine On
This will basically nullify all rewrite rules of parent folder.
Please check file-folder permission of myfolder. It should not be 777 instead it should be 755 on your server.
Please refer Wordpress php file execution

Categories