0

I have been using the server commands below in my .htaccess file for months without any problems, but yesterday, out-of-the-blue, whenever I attempted to navigate from the website homepage to other pages, or attempted to navigate through the Magento Admin settings pages, I got a mostly blank screen with the words "No input file specified" on it. I looked into the browser console and it listed the error as "Failed to load resource: the server responded with a status of 404 ()".

After some research, I determined that it was caused by the redirect commands in the public_html/.htaccess file.

I added the redirect at the urging of Magento, in order to not have sensitive Magento files available for the "public" to see/or use. (I am not using GoDaddy hosting or servers in any way). I got the redirect commands from a BlueHost or DreamHost webpage.

I have tried adding "?" and removing "/" from some of the commands, but it only shows a new error.

I also commented out the redirect commands allows me to navigate all throughout the website and the Magento Admin settings pages.

Can anyone point me in the right directions for what commands I need to use to have the redirects work properly, and a guide(s) as to what .htaccess commands do?

Thank you very much.

RewriteBase /public_html/pub

# Rewrites all URLs without pub in them
RewriteCond %{REQUEST_URI} !^/pub/

# Rewrites all URLs
RewriteCond %{HTTP_HOST} ^(www\.)?abc\.

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /pub/$1 [L]

1 Answer 1

0

By some miracle of God, my rewrite worked fine for months (rewrite newbie ignorance). But now, just before launching my eCommerce business, He helped me find the errors. Now to find out what is wrong with my MySQL tables.

My original code was missing some essential elements.

Below is working "code", and how it should look:

RewriteBase /public_html/pub

# Rewrites all URLs without pub in them
RewriteCond %{REQUEST_URI} !^/pub/$

# Rewrites all URLs  # I originally used "abc" instead of my domain name
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]  

# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /pub/$1 [L]

These are what the above elements mean:

! = negative/don't/not

\ = escape character

(.*) appears to be a wilcard to get all URL to go to the %{HTTP_HOST} rewritten location

NC = Case insens​itive, that is not case sensitive

L = Last (end of line/commands)- stop processing rules

^  = Start of the string

$ = End of the string

%{HTTP_HOST} = one of a few HTTP Headers

%{REQUEST_URI} = a kind of a special server variable that makes a request

1 appears to be shorthand for 301 which means "Moved perman​ently" as in rewrite these things permanently

? appears to be a URL break point, a domain name signifier, a subdirectory marker, or all of the above

I found a cheat sheat with these commands and others here: http://www.cheatography.com/davechild/cheat-sheets/mod-rewrite

I hope all of this helps some other rewrite newbies.

Thank everyone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .